Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
paolojolly
Creator
Creator

Error using variable in SQL script

Hello, I'm trying to use variable vART in the sql script


     SQL

        SELECT ITMREF_0, SUM(QTYSTU_0) AS QTYSTU FROM x145.JOLLY.STOJOU WHERE ITMREF_0 = $(vART)

            AND IPTDAT_0 <=  '20131231' GROUP BY ITMREF_0;

but I get the following error

SQL##f - SqlState: S0022, ErrorCode: 207, ErrorMsg: [Microsoft][ODBC SQL Server Driver][SQL Server]Il nome di colonna 'IBBHH001' non è valido.

SQL

        SELECT ITMREF_0, SUM(QTYSTU_0) AS QTYSTU FROM x145.JOLLY.STOJOU WHERE ITMREF_0 = IBBHH001

  AND IPTDAT_0 <=  '20131231' GROUP BY ITMREF_0

vART variable contains the item number (alphanumeric value) and it is assigned as follows:

  LET vART = TEXT('$(vID)');

I attach the example document

Can someone help me?

Thanks

2 Replies
nilesh_gangurde
Partner - Specialist
Partner - Specialist

Hi,

use single quote to evaluate the Variable .

Example.

SQL

        SELECT ITMREF_0, SUM(QTYSTU_0) AS QTYSTU FROM x145.JOLLY.STOJOU WHERE ITMREF_0 = '$(vART)'

            AND IPTDAT_0 <=  '20131231' GROUP BY ITMREF_0;

-Nilesh

paolojolly
Creator
Creator
Author

thank you, this helps me but now I have another problem in the for loop

Errore di riga Script:

FOR i = 1 TO

Errore di riga Script:

NEXT i

Tabella non trovata

DROP TABLES statement

I do not think that the sql is wrong

can you help me on this?

Thanks