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

Similar Messages

  • 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]

  • 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

    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

  • 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

  • Msg 137, Level 15, State 2, Line 29 Must declare the scalar variable "@ACTIVE_STATUS".

    USE [NC_DB]
    GO
    /****** Object:  StoredProcedure [dbo].[S_EDIT_USER]    Script Date: 12/23/2013 12:32:44 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[S_EDIT_USER]  
    (  @DSA_CODE VARCHAR(10)  
        ,@REQUESTOR_DEPT VARCHAR(40) 
        ,@ACTIVE_STATUS INT  
        ,@MAKER_ID VARCHAR(10)  
        ,@MAKER_IP VARCHAR(20)  
        ,@ERROR_CODE INT OUTPUT  
    AS  
    BEGIN  
    DECLARE @CNT INT;   
    DECLARE @SQL NVARCHAR(MAX);
    --DECLARE @REQUESTOR_DEPT VARCHAR(40);
    --print(@REQUESTOR_DEPT);
    SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;  
    IF @CNT > 0  
     SET @ERROR_CODE = 1;  
    ELSE  
     SET @ERROR_CODE = 0; 
    if @REQUESTOR_DEPT = 'N'
     SET @REQUESTOR_DEPT = ''; 
    ELSE  
     SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ; 
     print @REQUESTOR_DEPT;
    IF @ERROR_CODE = 0
    set @SQL = 'INSERT INTO TMAS_UAM_USER_TMP (  
       DSA_CODE  
               ,DSA_NAME  
               ,DSA_CITY  
               ,DSA_PRODUCT  
               ,DSA_PHNO  
               ,DSA_MOBNO  
               ,DSA_RQSTR  
               ,DSA_RQSTR_DEPT  
               ,GROUP_ID  
               ,ACTIVE_STATUS  
               ,REQ_TYPE  
               ,LAST_LOGED_IN  
               ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
               ,MAKER_ID  
               ,MAKER_IP  
               ,MAKER_DATE  
     ) SELECT DSA_COD  
         ,DSA_NAM  
         ,DSA_CTY  
         ,PRODUCT  
         ,DSA_PHO  
         ,DSA_MOB  
         ,REQUESTOR  
         ,'+@REQUESTOR_DEPT+'
         ,GROUP_ID  
         ,@ACTIVE_STATUS 
         ,1  
         ,LAST_LOG_DAT  
         ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
         ,'+@MAKER_ID+'  
         ,'+@MAKER_IP+'  
         ,GETDATE()  
        FROM DSA_MST WHERE DSA_COD = '+@DSA_CODE+' and ';
    if @REQUESTOR_DEPT = 'N'
    begin
    set @SQL = @SQL + 'REQUESTOR_DEPT is null';
    print('If Query'+@SQL);
    end
    else
    begin
        set @SQL = @SQL + 'REQUESTOR_DEPT = ''' + @REQUESTOR_DEPT + '''';
        print('Else Query'+@SQL);
        end
       --EXEC sp_executesql @SQL, N'@REQUESTOR_DEPT varchar(100) output', @REQUESTOR_DEPT output
    --EXECUTE sp_executesql @SQL;
    execute (@SQL);
    RETURN @ERROR_CODE;  
    END  

    The problem is that you are using dynamic SQL which you should not. Use the
    below instead. Uncomment the query hint if you are worried about
    performance.
    ALTER PROCEDURE [dbo].[S_EDIT_USER]  
    (  @DSA_CODE VARCHAR(10)  
        ,@REQUESTOR_DEPT VARCHAR(40) 
        ,@ACTIVE_STATUS INT  
        ,@MAKER_ID VARCHAR(10)  
        ,@MAKER_IP VARCHAR(20)  
        ,@ERROR_CODE INT OUTPUT  
    AS  
    BEGIN  
    DECLARE @CNT INT;   
    --DECLARE @REQUESTOR_DEPT VARCHAR(40);
    --print(@REQUESTOR_DEPT);
    SELECT @CNT = COUNT(*) FROM TMAS_UAM_USER_TMP WHERE DSA_CODE = @DSA_CODE;  
    IF @CNT > 0  
     SET @ERROR_CODE = 1;  
    ELSE  
     SET @ERROR_CODE = 0; 
    if @REQUESTOR_DEPT = 'N'
     SET @REQUESTOR_DEPT = ''; 
    ELSE  
     SET @REQUESTOR_DEPT = @REQUESTOR_DEPT ; 
     print @REQUESTOR_DEPT;
    IF @ERROR_CODE = 0
    INSERT INTO TMAS_UAM_USER_TMP (  
       DSA_CODE  
               ,DSA_NAME  
               ,DSA_CITY  
               ,DSA_PRODUCT  
               ,DSA_PHNO  
               ,DSA_MOBNO  
               ,DSA_RQSTR  
               ,DSA_RQSTR_DEPT  
               ,GROUP_ID  
               ,ACTIVE_STATUS  
               ,REQ_TYPE  
               ,LAST_LOGED_IN  
               ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
               ,MAKER_ID  
               ,MAKER_IP  
               ,MAKER_DATE  
     ) SELECT DSA_COD  
         ,DSA_NAM  
         ,DSA_CTY  
         ,PRODUCT  
         ,DSA_PHO  
         ,DSA_MOB  
         ,REQUESTOR  
         ,'+@REQUESTOR_DEPT+'
         ,GROUP_ID  
         ,@ACTIVE_STATUS 
         ,1  
         ,LAST_LOG_DAT  
         ,CREATED_ID  
         ,CREATED_IP  
         ,CREATED_DATE  
         ,'+@MAKER_ID+'  
         ,'+@MAKER_IP+'  
         ,GETDATE()  
        FROM DSA_MST
    WHERE DSA_COD = @DSA_CODE
     and  (REQUESTOR_DEPT = @REQUESTOR_DEPT OR @REQUESTOR_DEPT = 'N')
    -- OPTION (RECOMPILE)
    END  
    Erland Sommarskog, SQL Server MVP, [email protected]

  • 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

  • Where is it declared the return variable?

    Hi everyone,
    please which system privileges must you have to recompile a stored procedure owned by another application developer?
    and where is it declared the return variable?
    thank you

    In short you will need ALTER ANY PROCEDURE privilidge for that.
    Lets do a test for this:
    From User A:
    SQL> create table test as select * from user_objects where rownum<10;
    SQL> create procedure test_proc as
    2 begin
    3 delete test;
    4 commit;
    5 end;
    6 /
    Procedure created.
    Now from User Scott:
    alter procedure cr.test_proc compile
    ERROR at line 1:
    ORA-01031: insufficient privileges
    Now connect to user A and do the following:
    1* grant alter any procedure to scott
    SQL> /
    Grant succeeded.
    Now from Scott user:
    alter procedure cr.test_proc compile;
    Procedure altered.
    SQL> show errors
    No errors.
    Thats what you wanted.
    Riaz

  • I can't get rid of the message, n error occurred with the publication of album.  It just keep coming back, and can't move around in IPhoto.

    I can't get rid of the message, n error occurred with the publication of album.  It just keep coming back, and can't move around in IPhoto.

    Okay, folks, after a 3 1/2 hour phone call with a (very patient) telephone support person at Blackberry, here's what I learned.
    You can check your USB drivers this way:
    Plug in your phone into your USB drive. Assuming your Blackberry is "seen" by your computer...
    Go into the Device Manager on your computer (control panel)
    Expand the Universal Serial Bus controllers item on the bottom of the list
    Right-click on BlackBerry Smartphone and choose Properties
    Click on the Driver tab
    Click on the Driver Details button
    You should see one driver. I saw two. The one the BlackBerry likes is the RimUsb one.
    So here's what NOT to do: We tossed the entire driver that was the "extra". This effectively made using my mouse and keyboard impossible, as they are USB, and sent my poor husband into the basement to find a million-year-old keyboard (and then a mouse) with the old fashioned kind of connectors (PS2). Bleh. Don't do that.
    Here's what I did that worked (not saything this will work for you -- this modifies the Registry so better do a system backup with that backup and restore if you're nervous about this sort of thing):
    From the start menu, choose run, and type regedit to get into the Registry editor.
    Follow this file path: Computer, HKEY_LOCAL_MACHINE, SYSTEM, CurrentControlSet, Control, Class
    Click on: {36FCE60-C465-11CF-8056-4445535400000}
    If there's an item on the right called "UpperFilters", delete it. (see pictures)
    Hope this helps someone.
    Karin
    First pic: shows "before"
    Second pic: shows full file path and "after"

  • In Dreamweaver MySites[New Site] menu option , if I had a hosting JSP/PHP what I must declare the hosting JSP or PHP ?

    In Dreamweaver MySites[New Site] menu option , if I had a hosting JSP/PHP what I must declare the hosting JSP or PHP ?

    The simplest answer is to choose the language you work best with, and that fits the clients specification the best.
    I have mixed server languages on a site before, (would not recommend) when a client has decided they wish to change from their old one to a new(er) /different one, the only thing you must watch if doing this, is that you do not mix languages on the same page (will not work correctly, if at all), and parameter passing.
    PZ

  • How do I get rid of the community toolbar error message

    how do I get rid of the community toolbar error message

    Folks,
    Here is THE answer.  This has been a  problem of mine for MONTHS.  Use this link and it will DELETE that "community toolbar" notice.  Thanks to another person for posting this:
    http://thefreedictionarycom.ourtoolbar.com/uninstall/
    IT WORKS!

  • How do I get rid of the community toolbar error message when I select Safari?

    How do i get rid of the community toolbar error meessage when i select safari

    Folks,
    Here is THE answer.  This has been a  problem of mine for MONTHS.  Use this link and it will DELETE that "community toolbar" notice.  Thanks to another person for posting this:
    http://thefreedictionarycom.ourtoolbar.com/uninstall/
    IT WORKS!

  • How do I declare the extra variable?

    List the customer number, name, (first and last), order number, order date, employee number, employee, name (first and last), product number, product name, and order cost, (orderline.qty*prodprice) for products ordered on January 23, 2009
    I have no column called order cost in any tables. How do I declare a new variable called order cost in the query? And to date line is missing a right parenthesis. The exact line worked with a different question but accept that I have added on the date in this line.
    SELECT C.CUSTNO, C.CUSTFIRSTNAME, C.CUSTLASTNAME, O.ORNO, O.ORDDATE, E.EMPNO, E.EMPFIRSTNAME, E.EMPLASTNAME, P.PRODNO, P.PRODNAME, L.PRODNO, L.QTY, Order_cost
    From Customer c, Orders o, ORDERLINE L, Employee e, Product P
    where(C.CUSTNO=O.CUSTNO) and(O.EMPNO = E.EMPNO) and (O.ORDNO = L.ORDNO) and (P.PRODNO = L.PRODNO) and Order_cost= (L.QTY*ProdPrice)
    and (o.OrdDate >= to_date('23/01/2009', 'dd/'mm/yyyy') and o.OrdDate <= add_months(to_date('23/01/2009','dd/'mm/yyyy'),+1)-1);
    Thanks.

    Hi,
    user9164240 wrote:
    List the customer number, name, (first and last), order number, order date, employee number, employee, name (first and last), product number, product name, and order cost, (orderline.qty*prodprice) for products ordered on January 23, 2009
    I have no column called order cost in any tables. How do I declare a new variable called order cost in the query? And to date line is missing a right parenthesis. The exact line worked with a different question but accept that I have added on the date in this line.
    SELECT C.CUSTNO, C.CUSTFIRSTNAME, C.CUSTLASTNAME, O.ORNO, O.ORDDATE, E.EMPNO, E.EMPFIRSTNAME, E.EMPLASTNAME, P.PRODNO, P.PRODNAME, L.PRODNO, L.QTY, Order_cost
    From Customer c, Orders o, ORDERLINE L, Employee e, Product P
    where(C.CUSTNO=O.CUSTNO) and(O.EMPNO = E.EMPNO) and (O.ORDNO = L.ORDNO) and (P.PRODNO = L.PRODNO) and Order_cost= (L.QTY*ProdPrice)
    and (o.OrdDate >= to_date('23/01/2009', 'dd/'mm/yyyy') and o.OrdDate <= add_months(to_date('23/01/2009','dd/'mm/yyyy'),+1)-1);Never write, let alone post, unformatted code.
    Format your code so that it's easy to see (among other things) that
    (1) the arguments to TO_DATE match each other, and
    (2) parentheses are balanced.
    For example:
    SELECT      C.CUSTNO
    ,      C.CUSTFIRSTNAME
    ,      C.CUSTLASTNAME
    ,      O.ORNO
    ,      O.ORDDATE
    ,      E.EMPNO
    ,     E.EMPFIRSTNAME
    ,     E.EMPLASTNAME
    ,     P.PRODNO
    ,     P.PRODNAME
    ,     L.PRODNO
    ,     L.QTY
    ,     L.QTY * ProdPrice     AS Order_cost
    From      Customer     c
    ,     Orders           o
    ,     ORDERLINE     L
    ,     Employee     e
    ,     Product          P
    where     (C.CUSTNO     = O.CUSTNO)
    and     (O.EMPNO      = E.EMPNO)
    and      (O.ORDNO      = L.ORDNO)
    and      (P.PRODNO      = L.PRODNO)
    and      (o.OrdDate      >= to_date ( '23/01/2009'
                           , 'dd/'mm/yyyy'          -- WRONG!  Look at alignment
    and      o.OrdDate      <= add_months ( to_date ( '23/01/2009'
                                  , 'dd/'mm/yyyy'     -- WRONG!  Look at alignment
                              , +1
                              ) -1
    )                    -- Extra right parentheses
    ;When you post formatted text on this site, type these 6 characters
    \(all small letters, inside curly brackets) before and after each section of formatted text.  If you don't, this site will not show all the extra spaces.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How do I get rid of the AppleSyncNotifier.exe Error that keeps opening up everytime I start my computer?

    How do I get rid of the AppleSyncNotifier.exe message that comes on each time I start my PC?

    I'd first try uninstalling and then reinstalling your MobileMe control panel. Does that clear up the error?

  • Can't get rid of the itunes icon error

    i have a problem, i tried to update my ipod to the newer versiom but i cant get rid of the "itunes and usb icon" in the ipod. i tried to reset the ipod and its useless. Now my pc dosent recognize the ipod. Its an ipod touch
    Please i really need help..its been so many hours and i cant use my ipod..
    please if you can help me

    Did you try to connect in recovery mode? http://support.apple.com/kb/HT1808
    Also make sure Apple Mobile Device Service is active: http://support.apple.com/kb/TS1567

Maybe you are looking for

  • Pop up message on the variable screen in portal when report is run

    Hello I have a requirement to pop up a message stating " Date should not be entered before 2010 "on the variable screen of the report if date is entered before 2010 by the user when the report is run. Please can someone tell me how to implement this?

  • Build and Archive not available?

    I'm trying to build an application to test on a friends (windows based) computer, so I want to do the Build and Archive function and send them the file since they are remote. My app builds fine, loads in the simulator and everything, but this option

  • IPad slow when connected to Apple TV

    My iPad starts to opperate really slowly whenever it is connected to the Apple TV. when it is not connected to airplay it runs fine but as soon as air play is turned on it starts running really slowly. Can anyone help?

  • ISight on MacBook die

    I have a problem like Gabe with him iSight. After PRAM and PMU reseting, camera works few weeks and stop again. After that work just one day and stop again I think that a problem appears after new EFI firmware update and/or BootCamp Beta instalation,

  • Erroe Message:  Type Expected

    I need some help. I am getting the error message Type Expected with this line of code System.out.print("Your commission is $" + CommissionAmt); Any suggestions would be welcomed.