How do i declare a user defined table type sproc parameter as a local variable?

I have a procedure that uses a user defined table type.
I am trying to redeclare the @accountList parameter into a local variable but it's not working and says that i must declare the scalar variable @accountList.this is the line that is having the issue: must declare the scalar variable @accountListSET @local_accountList = @accountListALTER PROCEDURE [dbo].[sp_DynamicNumberVisits] @accountList AS integer_list_tbltype READONLY
,@startDate NVARCHAR(50)
,@endDate NVARCHAR(50)
DECLARE @local_accountList AS integer_list_tbltype
DECLARE @local_startDate AS NVARCHAR(50)
DECLARE @local_endDate AS NVARCHAR(50)
SET @local_accountList = @accountList
SET @local_startDate = @startDate
SET @local_endDate = @endDate
CREATE TYPE [dbo].[integer_list_tbltype] AS TABLE(
[n] [int] NOT NULL,
[n] ASC

Why are you asking how to be an awful SQL programmer??  Your whole approach to SQL is wrong.
We have a DATE data type so your insanely long NVARCHAR(50) of Chinese Unicode strings is absurd. Perhaps you can post your careful research on this? Can you post one example of a fifty character date in any language? 
The use of the "sp_" prefix has special meaning in T-SQL dialect. Good SQL programmers do not use CREATE TYPE for anything. It is dialect and useless. It is how OO programmers fake it in SQL. 
The design flaw of using a "tbl-" prefix on town names is called "tibbling" and we laugh at it. 
There are no lists in RDBMS; all values are shown as scalar values. First Normal Form (1NF)? This looks like a set, which would have a name. 
In any -- repeat any -- declarative programming language, we do not use local variables. You have done nothing right at any level. You need more help than forum kludges. 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • User defined table type output not coming

    hi all,
    i have a userdefined type delcared as:
    create or replace TYPE SAMPLE_SEARCH AS OBJECT (
    i have a user defined table type defined as:
    I have a stored proc which has an output paramter of type SAMPLE_sEARCH_TABLE.
    that is,
    sp_sample_proc(sample_search_tb OUT SAMPLE_SEARCH_TABLE);
    When i invoke the above stored proc from an anonymous pl/sql block , how can i display the contents of the output parameter using dbms_Output statements?

    Try this.........This is just a sample code.
    (country VARCHAR2(1000),
    city VARCHAR2(1000),
    zip NUMBER,
    add1 VARCHAR2(4000),
    add2 VARCHAR2(4000));
    CREATE OR REPLACE PROCEDURE Sp_Address_Obj(Out_Add_Obj OUT t_Addobj) IS
    v_Addobj t_Addobj := t_Addobj();
    SELECT Address1(u.Object_Name,
    'Add01' || Rownum,
    'Add02' || Rownum) BULK COLLECT
    INTO v_Addobj
    FROM User_Objects u;
    Out_Add_Obj := v_Addobj;
    END Sp_Address_Obj;
    v_Addobj t_Addobj := t_Addobj();
    FOR i IN 1 .. v_Addobj.Count LOOP
    Dbms_Output.Put_Line(v_Addobj(i).Country || '-' ||
    v_Addobj(i).City || '-' ||
    v_Addobj(i).Zip || '-' ||
    v_Addobj(i).Add1 || '-' ||

  • User defined table types sometimes show up a unknown data type in Profiler

    A couple of our users have a problem when using user defined table types. Calls are made using UDTT as variables and these are then passed to a stored procedure as parameters. Sometimes the application returns a timeout. In such situations a Profiler-Trace
    shows the following:
    declare @p4 unknown
    whereas the correct trace (that is sometimes displayed) should be:
    declare @p4 dbo.ReportFilterTableType
    ReportFilterTableType is a UDTT. The users do have correct permissions for the UDTT (otherwise they would never be usable for the user). What could be the reason that the data types for the variable
    @p4 in the example are sometimes returned as unknown and at other times are returned correctly as
    ReportFilterTableType? Could this possibly be a network related issue?
    Thank you.
    Graham Goodwin Email: [email protected]

    I know this is a old post, but i am also facing the same issue that too in my production server. Did you find any workarround for this issue. Please do reply. Critical problem we are facing.
    Alka, Is your problem timeouts when passing TVP parameters, or is it that a Profiler Trace shows type "unknown" for the TVP data type name?
    If your problem is timeouts, be aware that TVPs do not have statistics so the optimizer might not be able to generate an optimal plan for non-trivial queries. Declaring a primary key or unique constraint on the table type may help since that will provide
    useful cardinality information.  You may need to resort to hints in some cases.
    I suggest you start a new thread with details of your specific situation if the information in this thread doesn't help.
    Dan Guzman, SQL Server MVP,

  • User-Defined Table Types - Where is it in SQL Server 2008?

    I am having 2 issues:
    1.  I don't see a folder for 'User-Defined Table Types' under programmability-->Types
    2.  When I execute the following code to create a Type; I get an error 'Incorrect syntax near the keyword 'AS'.'
    USE Locations;
    /* Create a user-defined table type */
    CREATE TYPE LocationTableType AS TABLE
    ( LocationName VARCHAR(50)
    , CostRate INT );

    Hi Shayann,
    The  user-defined table type is a new
    feature from SQL Server 2008. If you want to use it you have to upgrade your database to SQL Server 2008 or above.
    In you scenario(SQL Server 2005),as a workaround, you can use the  local temporary table instead. 
    --in SQL Server 2005
    CREATE TABLE tblType(id INT,name VARCHAR(99))
    CREATE PROC proc1
    SELECT * FROM #temp;
    SELECT * INTO #temp FROM tblType; -- the #temp name is fixed
    INSERT INTO #temp VALUES(1,'Eric');
    EXEC proc1
    --In SQL Server 2008 or above
    CREATE TYPE LocationTableType AS TABLE
    ( id INT,
    name VARCHAR(99) );
    CREATE PROC proc1 @t LocationTableType READONLY
    SELECT * FROM @t
    DECLARE @t LocationTableType;
    INSERT INTO @t VALUES(1,'Eric');
    EXEC proc1 @t
    I still suggest you upgrade to higher SQL Server.
    If you have any question, feel free to let me know.
    Best regards,

  • Syntax error when creating a user-defined table type in SQL Server 2012

    Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
    CREATE TYPE ReportsTableType AS TABLE 
    ( reportId INT
    , questionId INT
    , questionOrder INT );
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'AS'.

    Hope these posts could help,
    Regards, Dineshkumar,
    Please Mark as Answer if my post answers your question and
    Vote as Helpful if it helps you

  • How to insert records in user defined tables through DI Server API

    Hi All,
    I have created a UDO using some userdefined tables .I am able to insert records in the user defined tables using DI API but problem is that now I want to insert records in those tables using DI Server API but I dont know how to do that please give me some way to do that
    Thanks and Regards

    The AddObject message is :
    <env:Envelope xmlns:env="">
        <dis:AddObject xmlns:dis="">
    How to use it with a user defined table ?

  • How to pass a user defined table type to stored procedure?

    I am trying to call a stored procedure from Java. The store procedure has three IN parameter, 2 IN/OUT params and 3 OUT parameters. The two IN/OUT parameters are user defined objects. Can anyone tell me how to set these IN/OUT parameters in Java.

    It is database/driver specific so you need to use the specific functionality of the driver (not jdbc) to access it.

  • How to Create CFL to user defined table

    Hi all,
    I have a user table with four fields. How to create a CFL for these fields?
    Fabio Ferreira.

    this is sub fn required for registration
    Here i mentioned heder level table and child table
    Fields are mentioned will be displayed on CFL
    If u want assign this CFL to any text field assign normal way but object id is:VEDA_PRN_WR_DOC
    Public Function UDOExists(ByVal code As String) As Boolean
            Dim v_UDOMD As SAPbobsCOM.UserObjectsMD
            Dim v_ReturnCode As Boolean
            v_UDOMD = objMain.objUtilities.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
            v_ReturnCode = v_UDOMD.GetByKey(code)
            v_UDOMD = Nothing
            Return v_ReturnCode
        End Function
    'Second fn
    Function registerUDO(ByVal UDOCode As String, ByVal UDOName As String, ByVal UDOType As SAPbobsCOM.BoUDOObjType, ByVal findAliasNDescription As String(,), ByVal parentTableName As String, Optional ByVal childTable1 As String = "", Optional ByVal childTable2 As String = "", Optional ByVal childTable3 As String = "", Optional ByVal LogOption As SAPbobsCOM.BoYesNoEnum = SAPbobsCOM.BoYesNoEnum.tNO) As Boolean
            Dim actionSuccess As Boolean = False
                registerUDO = False
                Dim v_udoMD As SAPbobsCOM.UserObjectsMD
                v_udoMD = objMain.objUtilities.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD)
                v_udoMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tNO
                v_udoMD.CanClose = SAPbobsCOM.BoYesNoEnum.tNO
                v_udoMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tNO
                v_udoMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES
                v_udoMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES
                v_udoMD.CanLog = LogOption
                v_udoMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tYES
                v_udoMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tYES
                v_udoMD.Code = UDOCode
                v_udoMD.Name = UDOName
                v_udoMD.TableName = parentTableName
                If LogOption = SAPbobsCOM.BoYesNoEnum.tYES Then
                    v_udoMD.LogTableName = "A" & parentTableName
                End If
                v_udoMD.ObjectType = UDOType
                For i As Int16 = 0 To findAliasNDescription.GetLength(0) - 1
                    If i > 0 Then v_udoMD.FindColumns.Add()
                    v_udoMD.FindColumns.ColumnAlias = findAliasNDescription(i, 0)
                    v_udoMD.FindColumns.ColumnDescription = findAliasNDescription(i, 1)
                If childTable1 <> "" Then
                    v_udoMD.ChildTables.TableName = childTable1
                End If
                If childTable2 <> "" Then
                    v_udoMD.ChildTables.TableName = childTable2
                End If
                If childTable3 <> "" Then
                    v_udoMD.ChildTables.TableName = childTable3
                End If
                If v_udoMD.Add() = 0 Then
                    registerUDO = True
                    objMain.objApplication.StatusBar.SetText("Successfully Registered UDO >" & UDOCode & ">" & UDOName & " >" & objMain.objCompany.GetLastErrorDescription, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success)
                    objMain.objApplication.StatusBar.SetText("Failed to Register UDO >" & UDOCode & ">" & UDOName & " >" & objMain.objCompany.GetLastErrorDescription, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
                    registerUDO = False
                End If
                v_udoMD = Nothing
            Catch ex As Exception
            End Try
        End Function
    This is a code for registration of table that will create CFL with mentioned fields.
    Hope help this
    Edited by: firoz101 on Aug 18, 2009 6:07 AM
    Edited by: firoz101 on Aug 18, 2009 6:08 AM
    Edited by: firoz101 on Aug 18, 2009 6:08 AM

  • How to add data in User Defined table

    Hello Experts,
    I have design form in screen painter , 3 text boxes and labels, 2 add buttons with uid 1 and 2 , and
    i have created tables and fields maually and registered new object i have also mentioned table name and alias in property box with fields i have created with userdefined fields as   ex: U_age etc and table @EMP in property box 
    I am loading this form as xml file to SAP B1 every thing works fine but when i click add button no data is added to table what is the problem
    Please suggest

    Are you using UDO or not?
    If not you have to write code by hand for manage data insert, update, search, and so on...

  • How to reference a pre-defined table type in entity definition

    I have a Table Type brc.sapere.gso.DDL::domain.TIME_PERIOD defined.
    I try to use it in an entity definition. (dbcommon.hdbdd is attached.)
    But there is an error saying
    ERROR      brc/sapere/gso/DDL/dbcommon.hdbdd
               CDS activation failed;Full qualified names are not allowed
    How can I reference the table type?

    Kalhari wrote:
    Hi, Thanks, but I've seen this. What I need to know is if there is a way to map "user defined table type" specifically, which is a new SQL type introduced with SQL 2008.1. Depends on the database.
    2. Depends on the JDBC driver
    3. Depends on JDBC spec that it being used.

  • How to fill the records from a User Define Table to PO item Grid

    Hi To all,
    I need to fill data from User Define table records into Purchase Order Item Grid.
    I created an UDF Filed in PO - Header Part - "PRS"(Filed Name)
    By using Formatted Search in itemcode column, i called a query,
    "Select itemcode, qty from (@user define tablename) where PRS = $http://OPOR.U_PRS"
    For eg:
    Output from querry
    ItemCode Qty
    ABC 1
    DEF 2
    DFG 7
    SDGD 9
    By using formatted search it is filling only first data in to itemcode column in PO Grid.
    Please help, how can i fill ALL the data in to my PO Grid?
    Thanks in Advance

    The easisest way is to create datasource and the result bind to grid.
               oDBDataSource = oForm.DataSources.DBDataSources.Add("@usertablename")
                Dim xoConditions As SAPbouiCOM.Conditions
                Dim xoCondition As SAPbouiCOM.Condition
                xoConditions = New SAPbouiCOM.Conditions
                xoCondition = xoConditions.Add
                xoCondition.BracketOpenNum = 1
                xoCondition.Alias = "u_zn"
                xoCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
                xoCondition.CondVal = "cond"
                xoCondition.BracketCloseNum = 1
    binding (example for matrix, in grid is simillar)
                Dim cols As SAPbouiCOM.Columns
                Dim column As SAPbouiCOM.Column
                cols = oMatrix.Columns
                column = cols.Item("colX")
                column.DataBind.SetBound(True, "@usertable", "u_x")
    hoep it helps

  • How to Execute User Defined Table in SQL?

    Hi Experts
    I have User Defined Table @SIN_MPLN in SAP B1 , i stored value in that User Defined Table and  if i execute that Table Through Query Generator it shows me value. it works fine.
    But when i go to SQL Server 2008 R2 and trying to execute this as..
    select * from @SIN_MPLN
    then it gives me Error --> Must declare the table variable "@SIN_MPLN"
    so please give me the answer

    Hello Navanath,
    Nagarajan's answer is correct.
    select * from [@SIN_MPLN] wil also work. the prefix "dbo" is not mandatory.
    Best Regards Teun


    Dear all , I am trying to transfer user defined table data,in new database ,can you please tell how i can do it

    Thanks for Quick responce
    I have Following databases
    1) Targate Database EOU TEST
    2) Source database  STI_BLANK
    Table @MACHINE
    I tried But it has some error
    INSERT INTO EOU [email protected]
    SELECT [email protected]* FROM [email protected]
    Edited by: Abhijit Bhise on Apr 1, 2010 3:27 PM
    Edited by: Abhijit Bhise on Apr 1, 2010 3:28 PM

  • How to add a DataBase Field in PLD from a User Defined Table

    Hi All,
    Please tell me how should i add a database field in PLD from User Defined Field...
    The DropDown for tables in the Property window does not shows the User Define tables...How should i see them...
    Thanx in Advance

    In PLD choose object Database. Then press Alt + table combobox, this will show the UDT. Then choose the column.

  • How to pop-up a text box for a grid item on a user defined table?

    I have a user defined table with a grid & one of the columns is for comments. What I'm trying to do is to pop up a text box when double clicking in the column field. This would be the same as the Item Details column in the Sales Order ittems grid.

    Please post your question on SDK forum.  Only SDK could meet your need.

Maybe you are looking for

  • Renaming a file when submitting

    Ok, I know this has been covered here before but I am a complete noob to this program. I have created a form (URL is listed at the bottom) for our advertising team to fill out when they are putting in a new order. For convenience, I'd like for the su

  • Transfering game saves, iphone 4 to iphone 5?

    Hi, my 5 is on its way and will be delivered soon, i have an iphone 4 at the moment. I understand settings, photos etc can be transferred through icloud, will this also include my saves for games like angry birds? if not whats the best way to go abou

  • Skype email address changed and fraud transaction ...

    Hi, I am a member of skype with the profile name 'anoopsaha'. Yesterday, someone changed my registered email address on skype from <my_email_id> to <my_email_id> Furthermore, they also charged US $30 on my credit card. In addi

  • Feature request: My O2 app widget

    it would be useful to have a widget showing used texts/minutes/data etc (particularly data) without having to open and sign in to the My O2 app each time

  • Embeded Videos won't play.

    I can play videos on Youtube just fine, but if I play them anywhere that they are embedded they don't work (like Facebook and I'm using Firefox 13.0.1, When I was using Firefox 12 everything was ok. I've tried Disabling my add-ons, running