Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

paolojolly
New Contributor III

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

Tags (1)
2 Replies
nilesh_gangurde
Valued Contributor

Re: Error using variable in SQL script

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
New Contributor III

Re: Error using variable in SQL script

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

Community Browser