Skip to Content
0

Query manager error

Jul 27, 2017 at 10:10 AM

54

avatar image
Former Member

Hello experts ,

i would like to save a query using Hana with two parameters but i received error .The query is the following :

DECLARE DATE1 SECONDDATE;
DECLARE METHOD1 NVARCHAR(100);
SELECT T1."U_date" INTO DATE1  FROM "@DATES" T1 WHERE T1."U_date"='[%0]';
SELECT T2."TrnspCode" INTO METHOD1 FROM "OINV" T2 WHERE T2."TrnspCode"='[%1]';

SELECT * FROM 
(SELECT "T1"."LicTradNum" ,"T1"."CardCode" ,"T1"."CardName" , "T1"."DocDate" , 
"T1"."DocDueDate", N'Τιμολόγιο' AS "Type" ,"T1"."DocNum", "T1"."PeyMethod", "T1"."TrnspCode", 
"T1"."GroupNum", "T1"."Comments","T3"."CityS", "T1"."DocTotal", "T1"."U_AdjAmount"   
FROM "OINV" T1 INNER JOIN "INV12" T3 ON "T1"."DocEntry" ="T3"."DocEntry"   
WHERE "T1"."DocDate" = :DATE1 AND T1."TrnspCode"= :METHOD1 AND "T1"."PeyMethod" IN 
(SELECT DISTINCT "Name" FROM "@ZAM_DELIVERY") AND "CANCELED" = 'N' 
AND "DocStatus"='O' 
UNION  
SELECT "T1"."LicTradNum" ,"T1"."CardCode" ,"T1"."CardName" , "T1"."DocDate" , "T1"."DocDueDate", 
N'Δελτιο Αποστολής' AS "Type" ,"T1"."DocNum" ,"T1"."PeyMethod" , "T1"."TrnspCode", "T1"."GroupNum", 
"T1"."Comments", "T3"."CityS","T1"."DocTotal", "T1"."U_AdjAmount"   
FROM "ODLN" T1 INNER JOIN "DLN12" T3 ON "T1"."DocEntry" ="T3"."DocEntry"   
WHERE "T1"."DocDate" = :DATE1  AND "T1"."TrnspCode"= :METHOD1 
AND "T1"."PeyMethod" IN (SELECT DISTINCT "Name" 
FROM "@ZAM_DELIVERY") AND "CANCELED" = 'N'  AND "DocStatus"='O'  
) Q1 
ORDER BY "Q1"."TrnspCode" , "Q1"."PeyMethod" , "Q1"."CardCode" , "Q1"."DocNum";

Kind Regards ,

Ifigeneia Koumbarda

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nagarajan K Jul 28, 2017 at 10:47 PM
0

Hi,

Don't use INTO command in any query. It may insert values to SAP tables.

The issue with your declared variables and it should be,

DECLARE DATE1 SECONDDATE;
DECLARE METHOD1 NVARCHAR(100);
Set @Date1 = (SELECT T1."U_date"  FROM "@DATES" T1 WHERE T1."U_date"='[%0]')
Set @Mthod1 = (SELECT T2."TrnspCode" FROM "OINV" T2 WHERE T2."TrnspCode"='[%1]')
Share
10 |10000 characters needed characters left characters exceeded