RecordSet message: Must Declare Table Variable

Hi
I am trying to read a table using a RecordSet
Private oRecordSet As SAPbobsCOM.Recordset
Dim oSqlString As String = "Select U_tno, U_cpro from @MX_N301"
Try
        oRecordSet.DoQuery(oSqlString)
Catch ex As Exception
And ex receives the next message:[Microsoft][ODBC SQL Server Driver][SQL Server]Must declate table variable "@MX_N301"
Can anybody tell me why I receive this message and what else do I have to do?
Thanks a lot

Hi Alberto,
for tables with  @ you need brackets !
"Select U_tno, U_cpro from [@MX_N301]"
regards
David

Similar Messages

  • Stored Proc with SSRS multi value parameter gives " Must Declare scalar Varaiable @StateID

    Hi All,
    I have one stored proc with @fromDate , @Todate and multivalue input
    parameter@StateID of type integer.
    When I run below stored proc via SSRS by selecting multiple values thru multiValue parameter into @StateID...it gives error saying "Must Declare scalar variable @StateID"
    Not sure what is wrong with the input parameters.
    ID is Integer type in all the 3 tables - dbo.EastCities, dbo.WestCities  , dbo.Country
    I need help fixing this  "Must Declare scalar variable @StateID" error
    This is the UDF split() I am using..
    Function:
    CREATE FUNCTION dbo.SplitStateID
    (    @List VARCHAR(MAX))
    RETURNS TABLE
    AS   
    RETURN   
    (        SELECT DISTINCT [Value] = CONVERT(INT, LTRIM(RTRIM(CONVERT( VARCHAR(12),SUBSTRING(@List, Number, CHARINDEX(',', @List + ',', Number) - Number))))
     FROM  dbo.Numbers       
     WHERE Number <= CONVERT(INT, LEN(@List))AND SUBSTRING(',' + @List, Number, 1) = ','    );
     GO
     SELECT [Value] FROM dbo.SplitStateID('10,30,50');
    Also, I have created dbo.Numbers table which is used in udf..
    reference url -- > 
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/01/processing-a-list-of-integers-my-approach.aspx
    SET NOCOUNT ON;
    DECLARE @UpperLimit INT;
    SET @UpperLimit = 10000;
    WITH n AS(   
    SELECT        rn = ROW_NUMBER() OVER        (ORDER BY s1.[object_id])   
    FROM sys.objects AS s1   
    CROSS JOIN sys.objects AS s2   
    CROSS JOIN sys.objects AS s3)
    SELECT [Number] = rn - 1
    INTO dbo.Numbers FROM n
    WHERE rn <= @UpperLimit + 1;
    CREATE UNIQUE CLUSTERED INDEX n ON dbo.Numbers([Number]);
    Stored procedure:
    Create Procedure dbo.CountrySelection
    ( @FromDate Date, @ToDate Date, @StateID Int)
    AS
    BEGIN
    set nocount on;
    SELECT * INTO #EastCities
    FROM (
    SELECT ID,Description from dbo.EastCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS A
    SELECT * INTO #WestCities
    FROM (
    SELECT ID,Description from dbo.WestCities
    Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
    ) AS B
    SELECT * INTO #Country
    FROM (
    SELECT ID , Description, State,Country From dbo.Country
    ) AS C
    SELECT EC.ID AS East, WC.ID AS West , EC.Description AS EastDesc, WC.Description AS WestDesc, CT.State, CT.Country
    FROM #Country CT
    LEFT JOIN #EastCities EC ON CT.ID=EC.ID
    LEFT JOIN #WestCities WC ON CT.ID=WC.ID
    DROP TABLE #EastCities
    DROP TABLE #WestCities
    DROP TABLE #Country
    END
    Above 3 temp tables are joined by #Country.ID key
    It works fine when single value is passed in @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010',10
    It fails when multi value passed into @StateID
    Exec dbo.CountrySelection '01/01/2010','02/01/2010','10,30,40'
    SSRS error log shows "Must declare scalar variable @StateID"
    Need help in fixing this issue.
    Thanks,
    RH
    sql

    Visakh,
    I changed @StateID date type to varchar(max) and still I get this error.  
    System.Data.SqlClient.SqlException: Must declare the scalar variable "@StateID".
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    I am running this SO in SSRS quert Type =Text
    Actually sp created on db2 database and due to some limitations I am running(via SSRS) this from different db1 database data source within the same db server. When I run this sp from SSRS query designer(edit query designer button) and pass
    multivalue parameters to @StateID as 10 , 20 it works and gives expected resultset.
    Thanks,
    RH
    sql

  • Declare @p1 variable error when creating multiple search form to show database info

    Hi, all help is incredibly appreciated,
    i have been trying to make a multiple filtered search form for a database in asp / vbscript. I want to be able to select from THIS database table, all info on the rows which id is BETWEEN x and x AND date is BETWEEN x and x AND securitynumber is BETWEEN x and x
    what would be the best way to do this?
    this is what ive got so far, which gives me the error:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@P1'.
    <%
    Dim rsBundleR__p_selectedDB
    rsBundleR__p_selectedDB = request.form("selectedDataBase")
    If (request.form("selectedDataBase") <> "") Then
      rsBundleR__p_selectedDB = request.form("selectedDataBase")
    End If
    %>
    <%
    Dim rsBundleR__p_idFrom
    rsBundleR__p_idFrom = request.form("bundleIdFrom")
    If (request.form("bundleIdFrom")  <> "") Then
      rsBundleR__p_idFrom = request.form("bundleIdFrom")
    End If
    %>
    <%
    Dim rsBundleR__p_idTo
    rsBundleR__p_idTo = request.form("bundleIdTo")
    If (request.form("bundleIdTo") <> "") Then
      rsBundleR__p_idTo = request.form("bundleIdTo")
    End If
    %>
    <%
    Dim rsBundleR__p_dateFrom
    rsBundleR__p_dateFrom = request.form("fromDate")
    If (request.form("fromDate") <> "") Then
      rsBundleR__p_dateFrom = request.form("fromDate")
    End If
    %>
    <%
    Dim rsBundleR__p_dateTo
    rsBundleR__p_dateTo = request.form("toDate")
    If (request.form("toDate") <> "") Then
      rsBundleR__p_dateTo = request.form("toDate")
    End If
    %>
    <%
    Dim rsBundleR__p_ssFrom
    rsBundleR__p_ssFrom = request.form("fromSS")
    If (request.form("fromSS") <> "") Then
      rsBundleR__p_ssFrom = request.form("fromSS")
    End If
    %>
    <%
    Dim rsBundleR__p_ssTo
    rsBundleR__p_ssTo = request.form("toSS")
    If (request.form("toSS") <> "") Then
      rsBundleR__p_ssTo = request.form("toSS")
    End If
    %>
    <%
    Dim rsBundleR
    Dim rsBundleR_cmd
    Dim rsBundleR_numRows
    Set rsBundleR_cmd = Server.CreateObject ("ADODB.Command")
    rsBundleR_cmd.ActiveConnection = MM_PHPSQL_STRING
    rsBundleR_cmd.CommandText = "SELECT * FROM ? WHERE id BETWEEN ? AND ?  AND fecha_solicitado BETWEEN ? AND ?  AND seguro_social BETWEEN ? AND ? ORDER BY id ASC"
    rsBundleR_cmd.Prepared = true
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param1", 200, 1, 255, rsBundleR__p_selectedDB) ' adVarChar
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param2", 5, 1, -1, rsBundleR__p_idFrom) ' adDouble
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param3", 5, 1, -1, rsBundleR__p_idTo) ' adDouble
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param4", 135, 1, -1, rsBundleR__p_dateFrom) ' adDBTimeStamp
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param5", 135, 1, -1, rsBundleR__p_dateTo) ' adDBTimeStamp
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param6", 200, 1, 255, rsBundleR__p_ssFrom) ' adVarChar
    rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param7", 200, 1, 255, rsBundleR__p_ssTo) ' adVarChar
    Set rsBundleR = rsBundleR_cmd.Execute
    rsBundleR_numRows = 0
    %>
    someone, please help, this is very important!

    allright i think thats what i did here:
      <% While ((Repeat1__numRows <> 0) AND (NOT rsBundleR.EOF)) %>
    <table align="center" border="1">
              <tr>
                <td align="left" width="50%">id</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("id").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">seguro_social</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("seguro_social").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">numero_estudiante</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("numero_estudiante").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apellido</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">celular</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("celular").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">email_pupr</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_pupr").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_fisica_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">email_personal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_personal").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_fisica</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_fisica").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">tipo_estudiante</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_estudiante").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">termino_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("termino_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apellido_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_1_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_referencia_1</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_1").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nombre_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">apllido_refencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("apllido_refencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">telefono_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_1_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">direccion_postal_2_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">ciudad_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estado_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">zona_postal_referencia_2</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_2").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">tipo_de_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_de_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">cantidad_prestamo</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("cantidad_prestamo").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">subsidiado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("subsidiado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">no_subsidiado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("no_subsidiado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">autorizo_pupr</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("autorizo_pupr").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">fecha_solicitado</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("fecha_solicitado").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">estatus</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("estatus").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">revisado_por</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("revisado_por").Value)%></td>
              </tr>
              <tr>
                <td align="left" width="50%">nota_personal</td>
                <td align="left" width="50%"><%=(rsBundleR.Fields.Item("nota_personal").Value)%></td>
              </tr>
            </table>
      <br /><br />
        <%
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      rsBundleR.MoveNext()
    Wend
    %>
    , no error is given BUT still, no information is showing.
    However, i dont see the "." either :/
    I made it create a table for each record,
    is it the way i called the information?
    or is the query not finding anything?
    ( there is information in the database )

  • Is it possible to create table variable by copying structure of existing table?

    Greetings community,
    It’s a newbie question.
    I’m still learning T-SQL, and I’m not very familiar with its syntax, so I’m not sure if I’m asking something stupid. I’m creating a “stored function”. I need to create temporary table variable to do some “thinking” in it and spit out a
    scalar result. Actually, I have to create about ten similar functions to process ten tables in similar way, so I was searching is it possible to speed it up.
    I was wondering is there any way, instead of declaring table variable with list of gazillion columns (and having the possibility to mistype something), to declare table variable so it would inherit structure of existing table.
    Thanks for any help.

    Temp table variable can not be created on the fly, but temp table can be created.
    If you want just the structure, you can use the below.
    SELECT Top 0
    INTO #temp
    FROM
    Sales.SalesOrderHeader

  • Query in SQL 2008R2 error Msg 1087, Level 15, State 2, Line 31 Must declare the table variable

    Hello Experts, 
    Can You help me; I get the follwing error in my query
    Msg 1087, Level 15, State 2, Line 31
    Must declare the table variable "@ASE_SUBART_GROEP".
    the @ASE_SUBART_GROEP is a self-defined table in this SQL environment.
    Maybe you know the error or the missing part
    Thanks in advance, Jos Dielemans

    I'm not familiar with SAP Business One unfortunately, so can only be of limited help here. But I'm going to guess that @ASE_SUBART_GROEP is a table variable passed to a stored procedure and is defined and passed down by the application, so you won't
    be able to copy-paste this code directly into management studio and get it to work.
    You could remove the join to return *all* records. Although the dataset might be very big
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(T1.Quantity * T2.SVolume) AS 'Aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.OINV T0
    INNER JOIN dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    UNION ALL
    SELECT T0.CardCode AS 'Klantnr'
    ,T0.CardName AS 'Klantnaam'
    ,T4.GroupName AS 'Klantgroep'
    ,T9.Descr AS 'Merknaam'
    ,T5.SlpName AS 'Verkoper'
    ,T3.MailCity AS 'Leverplaats'
    ,T7.NAME AS 'Leverland'
    ,T3.City AS 'Factuurplaats'
    ,T7.NAME AS 'Factuurland'
    ,T0.DocNum AS 'Documentnr'
    ,T0.DocDate AS 'Datum'
    ,Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) AS 'Jaar'
    ,RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2) AS 'Maand'
    ,(Cast((Datepart(Year, T0.DocDate)) AS VARCHAR) + '-' + RIGHT('00' + CAST(DATEPART(MONTH, T0.DocDate) AS VARCHAR(2)), 2)) AS 'Periode'
    ,T1.ItemCode AS 'Artikelnr'
    ,T2.ItemName AS 'Artikelnaam'
    ,- T1.Quantity AS 'Aantal VEH'
    ,T2.SVolume AS 'Aantal EH per VEH'
    ,(- T1.Quantity * T2.SVolume) AS 'aantal EH'
    ,T8.UnitName AS 'EH-Naam'
    ,T6.ItmsGrpNam AS 'Artikelgroep'
    ,T2.U_ItemGrp AS 'Hoofdgroep'
    ,T10.NAME AS 'Subgroep'
    ,T1.CogsAcct AS 'Kostpr.rek.'
    ,T1.AcctCode AS 'Opbrengstrek.'
    ,- T1.LineTotal AS 'BrutoOmzet'
    ,T0.DiscPrcnt AS 'Korting'
    ,(+ T1.LineTotal * (100 - T0.DiscPrcnt) / 100) AS 'NettoOmzet'
    FROM dbo.ORIN T0
    INNER JOIN dbo.RIN1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
    INNER JOIN OCRD T3 ON T0.CardCode = T3.CardCode
    INNER JOIN OCRG T4 ON T3.GroupCode = T4.Groupcode
    INNER JOIN OSLP T5 ON T3.SlpCode = T5.SlpCode
    INNER JOIN OITB T6 ON T2.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OCRY T7 ON T3.Country = T7.Code
    LEFT OUTER JOIN OLGT T8 ON T2.SVolUnit = T8.UnitCode
    LEFT OUTER JOIN UFD1 T9 ON T3.U_ZPgroep = T9.FldValue
    AND TableID = 'OCRD'
    AND FieldID = 2
    --LEFT OUTER JOIN @ASE_SUBART_GROEP T10 ON T2.U_ASE_SUB_ARTGROEP = T10.Code
    WHERE T0.DocDate >= '20120101'
    AND T0.Canceled = 'N'
    ORDER BY T0.CardCode
    The join to the table variable has been commented out above, so the code should run. After that you might want to update the WHERE clause to include only particular sub-groups

  • Must declare the Scalar variable *@prompt*.. (IES 10901)".

    Hi,
    I am getting an error: "Database error Must declare the Scalar variable *@prompt*.. (IES 10901)".
    backend: SQLServer
    The dim, Lovs are valid in IDT universe.
    There is a Fiscal Year Month Dim in Universe=SELECT
      cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int)
    FROM "COST_SUMMARY_FACT_VR"
    Lov
    There are two LOVs FP_From, FP_To
    1) FP_From= select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
    2) FP_To=select distinct cast(convert(varchar(6),DATEADD (YEAR,"COST_SUMMARY_FACT_VR"."FISC_YEAR"-1900,DATEADD(MONTH,"COST_SUMMARY_FACT_VR"."FISC_PERIOD"-1,DATEADD(DAY,0,0 ))),112) as int) from COST_SUMMARY_FACT_VR order by 1
    Prompts
    There are two universe prompts
    1) FP_From is Numeric and LOV FP_From is attached
    2) FP_To is Numeric and LOV FP_To is attached
    Using the universe prompts in webi as
    Fiscal Year Month between FP_From and FP_To
    Qry is executing perfectly in backend.

    In addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
    Also, you should the dynamic SQL this way:
    SET @sql = N'
    SELECT @Result=COUNT( Id ) FROM  ' + quotename(@TableName) +
    ' WHERE RunRegisterKey=@ID'
    SET @Params = N'@Result int OUTPUT, @ID int'
    EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
    That is, use quotename for the table name, in case you have a table named
    sys.objects; SHUTDOWN WITH NOWAIT; --
    Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Must declare the scalar variable error

    I am getting the error "Must declare the scalar variable "@Result""  when i execute the below query
    declare @sql nvarchar(max),
    @tablename varchar(200),
    @Id int,
    @Result int
    set @tablename='xyz'
    set @id=1
    SET @sql = '
    SELECT @Result=COUNT( Id ) FROM  ' + @TableName+ ' WHERE RunRegisterKey=' +convert(nvarchar(100),@ID)  
    EXEC sys.sp_executesql @sql

    In addition to Visakh's solution: the reason you got the error message is because the piece of dynamic SQL is not part of the stored procedure, but constiutes a scope of its own. Thus variables declared in the surrounding procedure are not visible.
    Also, you should the dynamic SQL this way:
    SET @sql = N'
    SELECT @Result=COUNT( Id ) FROM  ' + quotename(@TableName) +
    ' WHERE RunRegisterKey=@ID'
    SET @Params = N'@Result int OUTPUT, @ID int'
    EXEC sys.sp_executesql @sql,@Params,@Result = @Result OUT, @ID = @ID
    That is, use quotename for the table name, in case you have a table named
    sys.objects; SHUTDOWN WITH NOWAIT; --
    Furthermore, pass @ID as a parameter rather than concatenating it to the string. It is both easier and safer.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Error must declare the scalar variable

    por que me marca ese error una consulta?
    DECLARE  @feci AS datetime
    DECLARE @fecf AS datetime
    SET @FECI=(SELECT DISTINCT(T0.DOCDATE) FROM ORTT T0 WHERE T0.DOCDATE='[%0]')
    SET @FECF=(SELECT DISTINCT(T0.DOCDATE) FROM ORTT T0 WHERE T0.DOCDATE='[%1]')
    EXEC DBO.COMPARATIVO @FECI,@FECF
    Edited by: mary merecias on Nov 17, 2011 3:15 PM

    el codigo no, son las variables. si pongo este código me marca que no tiene un select MUST SPECIFY TABLE TO SELECT FROM
    Declare @fec1 as datetime
    Declare @fec2 as datetime
    SET @fec1=[%0]
    SET @fec2=[%1]
    SELECT DISTINCT(T0.itemcode),T0.itemname,T0.onhand,     
          (SELECT SUM(PCH1.linetotal) AS TOTAL
               FROM OPCH
                  INNER JOIN pch1 on OPCH.docentry=PCH1.docentry
                INNER JOIN OITM ON OITM.ITEMCODE=PCH1.ITEMCODE
               WHERE pch1.targettype<>'19' and OITM.itemcode=T0.ITEMCODE AND OPCH.DOCDATE>=@FEC1 AND OPCH.DOCDATE<=@fec2)AS 'TOTAL COMPRAS',
         (SELECT SUM(PCH1.QUANTITY) AS TOTAL
               FROM OPCH
                  INNER JOIN pch1 on OPCH.docentry=PCH1.docentry
                INNER JOIN OITM ON OITM.ITEMCODE=PCH1.ITEMCODE
               WHERE pch1.targettype<>'19' and OITM.itemcode=T0.ITEMCODE AND OPCH.DOCDATE>=@fec1 AND OPCH.DOCDATE<=@fec2 ) AS 'PIEZAS COMPRADAS',
          (SELECT SUM(INV1.linetotal) AS TOTAL
               FROM OINV
                  INNER JOIN INV1 on OINV.docentry=INV1.docentry
                INNER JOIN OITM ON OITM.ITEMCODE=INV1.ITEMCODE
               WHERE INV1.targettype<>'14' and OITM.itemcode=T0.ITEMCODE AND OINV.DOCDATE>=@fec1 AND OINV.DOCDATE<=@fec2)AS 'TOTAL VENTAS',
         (SELECT SUM(INV1.QUANTITY) AS TOTAL
               FROM OINV
                  INNER JOIN INV1 on OINV.docentry=INV1.docentry
                INNER JOIN OITM ON OITM.ITEMCODE=INV1.ITEMCODE
               WHERE INV1.targettype<>'14' and OITM.itemcode=T0.ITEMCODE AND OINV.DOCDATE>=@fec1 AND OINV.DOCDATE<=@fec2 ) AS 'PIEZAS VENDIDAS'
         FROM OITM T0
    GROUP BY T0.itemcode,T0.itemname,T0.onhand
    en SQL SERVER si funciona bien
    Edited by: mary merecias on Nov 17, 2011 4:50 PM
    Edited by: mary merecias on Nov 17, 2011 4:51 PM
    Edited by: mary merecias on Nov 17, 2011 4:53 PM

  • Getting "Must declare the scalar variable" Error

    Hello All,
    I have write following query to block invoice which has Prices not equal to PriceList as below.
    -- To Block Invoices which has Prices not equal to PriceList
    IF (@transaction_type='A' OR @transaction_type = 'U') AND CAST(@OBJECT_TYPE = '18')
    BEGIN
        SELECT T1.ItemCode,
                T1.Price AS PO_Price,
                T2.U_ListPrice AS Listed_Price
            FROM OPCH AS T0 
            INNER JOIN
            PCH1 AS T1 ON
            T0.DocEntry = T1.DocEntry
            LEFT OUTER JOIN    
            [dbo].[@PRICELISTS] AS T2 ON
            T1.ItemCode = T2.U_ItemNo
        WHERE
                    T1.DocEntry = @list_of_cols_val_tab_del) AND
            (T1.Price <> T2.U_ListPrice)   
    BEGIN
    SET @error = 123
    SET @error_message = 'Deviation in price'
    END
    END
    But after Execution got following Errors
    Msg 137, Level 15, State 2, Line 2
    Must declare the scalar variable "@transaction_type".
    Msg 137, Level 15, State 2, Line 19
    Must declare the scalar variable "@list_of_cols_val_tab_del".
    Msg 137, Level 15, State 1, Line 22
    Must declare the scalar variable "@error".
    Msg 137, Level 15, State 1, Line 23
    Must declare the scalar variable "@error_message".
    Please Help
    Regards
    Hitul

    Hi Hitul,
    Please check Snapshot.
    Please see Red Lines for SBO_SP_TransactionNotification Procedure.
    Paste your code below ADD YOUR CODE HERE.
    Hope this help
    Regards::::
    Atul Chakraborty

  • Must declare the scalar variable

    I Am getting error as Must declare the scalar variable "@Imageid" for the following code,while executing,
    exec spGetPager  ' ' , ' ', ' 3 ', ' '
    In my coding I pass querystring value like 1,2,3 etc
    CREATE PROCEDURE spGetPager
          @PageNo int = 1,  
          @ItemsPerPage int = 1,  
     @Imageid int,
          @TotalRows int out  
    AS  
    BEGIN  
      SET NOCOUNT ON  
      DECLARE  
        @StartIdx int,  
        @SQL nvarchar(max),   
        @SQL_Conditions nvarchar(max),   
        @EndIdx int
          IF @PageNo < 1 SET @PageNo = 1  
          IF @ItemsPerPage < 1 SET @ItemsPerPage = 10  
          SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1  
          SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1  
          SET @SQL = 'SELECT Imageid,Imagepath,imagename,username  
                    FROM (  
                    SELECT  ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *  
                          FROM  Imageupload ) AS tbl WHERE Imageid=@Imageid AND Row >= '  
                                        + CONVERT(varchar(9), @StartIdx) + ' AND  
                           Row <=  ' + CONVERT(varchar(9), @EndIdx)  
          EXEC sp_executesql @SQL  
          SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'  
          EXEC sp_executesql  
            @query = @SQL,  
            @params = N'@TotalRows INT OUTPUT',  
            @TotalRows = @TotalRows OUTPUT  
    END
    Thanks in Advance

    you cant use variable directly in concatenation operator as its of type int. you need to cast it first as below
    CREATE PROCEDURE spGetPager
    @PageNo int = 1,
    @ItemsPerPage int = 1,
    @Imageid int,
    @TotalRows int out
    AS
    BEGIN
    SET NOCOUNT ON
    DECLARE
    @StartIdx int,
    @SQL nvarchar(max),
    @SQL_Conditions nvarchar(max),
    @EndIdx int
    IF @PageNo < 1 SET @PageNo = 1
    IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
    SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
    SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
    SET @SQL = 'SELECT Imageid,Imagepath,imagename,username
    FROM (
    SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
    FROM Imageupload ) AS tbl WHERE Imageid=' + CAST(@Imageid AS varchar(50)) + ' AND Row >= '
    + CONVERT(varchar(9), @StartIdx) + ' AND
    Row <= ' + CONVERT(varchar(9), @EndIdx)
    EXEC sp_executesql @SQL
    SET @SQL = 'SELECT @TotalRows=COUNT(*) FROM Imageupload'
    EXEC sp_executesql
    @query = @SQL,
    @params = N'@TotalRows INT OUTPUT',
    @TotalRows = @TotalRows OUTPUT
    END
    That being I didnt understand why you need dynamic sql here. There's no dynamicity involved as i see
     you could simply use a sql like below
    CREATE PROCEDURE spGetPager
    @PageNo int = 1,
    @ItemsPerPage int = 1,
    @Imageid int,
    @TotalRows int out
    AS
    BEGIN
    SET NOCOUNT ON
    DECLARE
    @StartIdx int,
    @EndIdx int
    IF @PageNo < 1 SET @PageNo = 1
    IF @ItemsPerPage < 1 SET @ItemsPerPage = 10
    SET @StartIdx = (@PageNo -1) * @ItemsPerPage + 1
    SET @EndIdx = (@StartIdx + @ItemsPerPage) - 1
    SELECT Imageid,Imagepath,imagename,username
    FROM (
    SELECT ROW_NUMBER() OVER(ORDER BY Imageid) AS Row, *
    FROM Imageupload ) AS tbl WHERE Imageid=@Imageid
    AND Row >= @StartIdx
    AND Row <= @EndIdx
    SELECT @TotalRows=COUNT(*) FROM Imageupload
    END
    to achieve same requirement.
    Make sure you read
    http://www.sommarskog.se/dynamic_sql.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Simple command to refresh data of all declared internal tables & variables!

    Hi All,
    I have declared many internal tables & variables in my program in declaration include.
    Is there any Simple command which can refresh data of all declared internal tables & variables!
    Instead of clearing & refreshing each i.table & variable i want to use single command to refresh data.
    Is this possible!
    Thanks in advance.
    Thanks,
    Deep.

    CLEAR: lv_field1,
                 lv_field2,
                 lt_itab1[],
                 lt_itab2[].
    ONE simple command (CLEAR), can initialize fields, workareas, field-symbols,.... and internal tables.

  • I am getting this error message "ORA-01006: bind variable does not exist.

    My code works fine like this:
    DECLARE
    v_JOBTYPE varchar2(8);
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    BEGIN
    SELECT EVT_STATUS, EVT_FAILURE, EVT_CAUSE, EVT_ACTION, EVT_JOBTYPE
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, v_JOBTYPE
    FROM R5EVENTS WHERE ROWID = :ROWID;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(v_JOBTYPE , 'X') IN ('BRKD','UNPLBRKD','FILTRA', 'LUB', 'FAC') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;
    But I want to change the code to include a record (ACT_TRADE) from another table(R5ACTIVITIES). I am getting this error message "ORA-01006: bind variable does not exist - POST-UPDATE 200Before Binding". Any help would be appreciated.
    DECLARE
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    V_CODE varchar2(8);
    V_EVENT varchar2(8);
    V_TRADE varchar2(8);
    BEGIN
    SELECT R5EVENTS.EVT_STATUS, R5EVENTS.EVT_FAILURE, R5EVENTS.EVT_CAUSE, R5EVENTS.EVT_ACTION, R5EVENTS.EVT_CODE, R5ACTIVITIES.ACT_EVENT, R5ACTIVITIES.ACT_TRADE
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, V_CODE, V_EVENT, V_TRADE
    FROM R5EVENTS, R5ACTIVITIES WHERE V_CODE = :V_EVENT;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(v_TRADE , 'X') IN ('MTM','MTL','MTMGT', 'FTM', 'FTL', 'FTMGT', 'R5') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;

    Thank you for your responses. Your feedback was helpful. This is what I ended up doing for a solution:
    DECLARE
    v_JOBTYPE varchar2(8);
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    v_GROUP varchar2(30);
    BEGIN
    SELECT EVT_STATUS, EVT_FAILURE, EVT_CAUSE, EVT_ACTION, EVT_JOBTYPE, USR_GROUP
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, v_JOBTYPE, v_GROUP
    FROM R5EVENTS, R5USERS WHERE R5EVENTS.ROWID = :ROWID
    AND USR_CODE = O7SESS.CUR_USER;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(V_GROUP,'X') IN ('MTM','MTL','MTMGT','FTL','FTMGTS','PLANNER','DISPATCH','PMCOOR','R5') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;

  • Must specify table to select from

    hi everybody
    i think  sometime we received this error message:
    1).[Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to selet from. 2).[Microsoft][SQL Server Native Client 10.0][SQL Server]Statment 'Contrato de Servicio' (OCTR)(s) could not be prepared.
    when i'm working in SQL Server the qry run fine, but when i run in SAP, i receive the error before mentioned.
    the Qry is this:
    DECLARE @FechaIni datetime,     
            @FechaFin datetime,
            @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni = [%0]
    SET @FechaFin = [%1]
    CREATE TABLE #Libo_Mayor_CS (
                                    CodCta nvarchar(max),
                                    CtasPadre nvarchar(max),
                                    NbreCta nvarchar(max),
                                    Nivel numeric(1),
                                    Rubro numeric(1),
                                    SldoInicial numeric(19,6),
                                    Debe numeric(19,6),
                                    Haber numeric(19,6),
                                    SldoFinal numeric(19,6)
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] <=3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           0.00,
           0.00,
           0.00,
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode] = T1.[Account]
    WHERE T0.[Levels] BETWEEN 1 AND 3 AND
          T0.[GroupMask]   BETWEEN 1 AND 5
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] >3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           CASE
               WHEN T0.GroupMask  = 1 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 2 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 4 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 5 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
           END,
           SUM(T1.[Credit]),
           SUM(T1.[Debit]),
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode]  = T1.[Account]
    WHERE T0.[Levels] > 3 AND
          T0.[GroupMask]  BETWEEN 1 AND 5 AND
         (T1.[RefDate] between @FechaIni AND @FechaFin)
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    SELECT A.[CodCta] 'Codigo de Cuenta',
           A.[CtasPadre] 'Cuentas Padre',
           A.[NbreCta] 'Nombre de Cuenta',
           A.[Nivel] 'Nivel',
           A.[Rubro] 'Rubro',
           A.[SldoInicial] 'Saldo Inicial',
           A.[Debe] 'Debito',
           A.[Haber] 'Credito',
           CASE
               WHEN A.[Rubro] = 1 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 2 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               WHEN A.[Rubro] = 4 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 5 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               ELSE 0
           END 'Saldo'
    FROM #Libo_Mayor_CS A
    ORDER BY A.[CodCta]
    DROP TABLE #Libo_Mayor_CS
    if  assign the value to variables directly the Qry run in SAP but when i change the comodin to capture the variables value of SAP , there is when the problem ocurre
    DECLARE @FechaIni datetime,     
                    @FechaFin datetime,
                    @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni =  '20110601'
    SET @FechaFin = '20110630'
    i wait for your recomendations
    Edited by: AlexMeza on Jun 15, 2011 1:29 AM

    Hi all !
    Sorry because i dont know where post new.
    My issue, when i using querry manager to call store in Database like this
    Declare @Fromdate Datetime
    Declare @Todate Datetime
    Declare @AcctCode nvarchar (20)
    set @Fromdate = (select distinct (T1.RefDate) from OJDT T1 where T1.RefDate = '[%0]')
    set @Todate = (select distinct (T2.RefDate) from OJDT T2 where T2.RefDate = '[%1]')
    set @AcctCode = (select distinct(T3.AcctCode) from OACT as T3 where T3.AcctCode ='[%2]' )
    exec [USP_RPT_FI_GENERALLEDGER] @Fromdate, @Todate, @AcctCode
    and i run this querry
    this error:
    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'Service Contracts' (OCTR) (s) could not be prepared.
    Please help me fix this issue
    Regards!
    John Le.

  • Open sys_refcursor for select from table variable?

    Hi,
    I've got a challenge for you! :-)
    I've got a procedure that has a lot of logic to determine what data should be loaded into a table variable. Because of various application constraints, i can not create a global temporary table. Instead, i'd like to create a table variable and populate it with stuff as i go through the procedure.
    The end result of the procedure is that i must be able to pass the results back as a sys_refcursor. This is a requirement that is beyond my control as well.
    Is there a way to make this sort of procedure work?
    Create Or Replace Procedure Xtst
    Mu_Cur In Out Sys_Refcursor
    Is
    Type Xdmlrectype Is Record (Col1 Varchar2(66));
    Type Xdmltype Is Table Of Xdmlrectype;
    Rtn Xdmltype;
    Begin
    Select Internal_Id Bulk Collect Into Rtn From Zc_State;
    open mu_cur for select col1 from table(rtn);
    end;
    11/42 PLS-00642: local collection types not allowed in SQL statements
    11/36 PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    11/19 PL/SQL: SQL Statement ignored
    Show Errors;

    Not anything i'd want to personally implement.
    But for educational purposes only of course....
    create table this_will_be_gross
       column1 number,
       column2 varchar2(30)
    insert into this_will_be_gross values (1, 'begin the ugliness');
    insert into this_will_be_gross values (2, 'end the ugliness');
    variable x refcursor;
    ME_XE?
    declare
       Rtn sys.ODCIVARCHAR2LIST;
    BEGIN
       SELECT
          column1 || '-' || column2 Bulk Collect
       INTO
          Rtn
       FROM
          this_will_be_gross;
       OPEN :x FOR
       SELECT 
          regexp_substr (column_value, '[^-]+', 1, 1) as column1,
          regexp_substr (column_value, '[^-]+', 1, 2) as column2      
       FROM TABLE(CAST(rtn AS sys.ODCIVARCHAR2LIST));
    end;
    17  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.09
    ME_XE?
    ME_XE?print :x
    COLUMN1                        COLUMN2
    1                              begin the ugliness
    2                              end the ugliness
    2 rows selected.
    Elapsed: 00:00:00.11In the above example i 'knew' that a hypen was a safe character to use to break up my data elements (as it would not be found anywhere in the data itself).
    I would strongly encourage you not to implement something like this. I realize it's tempting when you are working in strict environments where it can take a serious battle to get structures like temporary tables or SQL Types created, but that's really the proper approach to be taking.

  • Using a dynamic table variable in a stored procedure

    SQL Server can do this where you declare a table variable and insert / modify / delete rows in that table without it ever being actually ON the database.
    Can Oracle do this?
    I know I can do things like pass in a unique user id, create the table in the procedure with the user ID appended, etc ...
    but this procedure is going to be accessed via two modes, a batch job as well as online. The batch job may run this procedure 500 times.
    What I'm trying to is figure out a way to return a recordset of errors that occured in the job, simple, 3 lines like so:
    LineNumber NUMBER,
    Severity VARCHAR(10),
    Error_Msg VARCHAR(200)
    is there any 3 dimensional way of storing these records when the errors occur, then returning them as a select statement at the end of the procedure?
    Thanks,

    Why not create a table
    CREATE TABLE error_log (
      job_id  NUMBER,
      line_number NUMBER,
      severity VARCHAR2(10),
      error_msg VARCHAR2(200)
    CREATE SEQUENCE seq_error_log_job_id
      START WITH 1
      INCREMENT BY 1
      CACHE 100;In your procedure, you would get a new job_id from the sequence, insert whatever records you want in the error log table using that job_id and then return a REF CURSOR where you select from the error_log table using the job_id.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • Block Line items in sales order with no confirmation and auth check

    Hi. We have a requirement to block some line items ( hold for review ) in a sales order while allowing other line items to be delivered.  In the standard SAP system, a schedule line block is possible, but it does not remove the confirmation for the l

  • Maybe a bug? using  DBMS_XMLGen.ctxHandle;

    Hi all, I use a Oracle 10g Database, and i don't know if the following is a bug or i have done something wrong. I am trying: CREATE OR REPLACE PROCEDURE MAIN.PRUEBA_XML IS v_xml clob; v_ctx DBMS_XMLGen.ctxHandle; doc xmldom.DOMDocument; BEGIN DBMS_LO

  • Oracle 11g DB installation failed when checking Prerequisite.

    Hi, I am installing Oracle 11g DB in linux box using the shiphome "/net/stlinma7.us.oracle.com/vol/shiphomes_linux/rdbms/11.1.0/11.1.0.2/11102-BETA3". During installation process when i get "Product-Specific Prerequisite Checks" wizard screen, I am g

  • URGENT: Mask on Total value

    Hi all, I have a customer who needs to format the Total value on a classic table to show it with 4 decimal places like this 10,500.0000. In order to achieve such requirement I tried the following code in 'processRequest' method, but no success. OATab

  • Sorting not happening in portal.

    Hi All, I want to display top ten customer based on revenue and sorted depending on posting period infoobject. Under columns section we have posting period and amount being displayed and under row section we have customer infoobject. I am not able to