Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
odaher123
Contributor II
Contributor II

Variable Qlikview in SQL Select

Hello everyone,
How with a SQL connection, recover data that has not been repatriated since the last connection and are stored in a QVD file (Ecritures.qvd)?
I can not use the $ (Maxpiece) variable with the SQL SELECT statement with the Where condition.
You will find below my script which does not accept the variable
thank you for your help

========================

LOAD

    Max(EC_No) as Maxpiece,

FROM

(qvd);

ODBC CONNECT TO BASE_LOCAL2 (XUserId is bbbRdYRNJbaMXUVMXTcB, XPassword is vvVYaRdNrLacWXJObA);

Ecritures:

SQL SELECT *

FROM ACHATS.dbo."ECRITURES"

Where (EC_No > $(Maxpiece));

============================================

1 Solution

Accepted Solutions
odaher123
Contributor II
Contributor II
Author

Hi Ruben
Thank you for your answer, it was almost correct but it did not work. I found in the meantime how to do it and here is the solution.

LOAD

    Max(EC_No) as MaxNo,

FROM

(qvd);

Let Maxpiece = peek(‘MaxNo’) ;

ODBC CONNECT TO BASE_LOCAL2 (XUserId is bbbRdYRNJbaMXUVMXTcB, XPassword is vvVYaRdNrLacWXJObA);

Ecritures:

SQL SELECT *

FROM ACHATS.dbo."ECRITURES"

Where (EC_No > $(Maxpiece));

View solution in original post

3 Replies
rubenmarin

Hi Olivier, in that code Maxpiece is a field, not a variable, you can create a variable of that field value:

LET vMaxpiece = Peek('Maxpiece',0);


And use this variable in where:

Where (EC_No > $(vMaxpiece));

odaher123
Contributor II
Contributor II
Author

Hi Ruben
Thank you for your answer, it was almost correct but it did not work. I found in the meantime how to do it and here is the solution.

LOAD

    Max(EC_No) as MaxNo,

FROM

(qvd);

Let Maxpiece = peek(‘MaxNo’) ;

ODBC CONNECT TO BASE_LOCAL2 (XUserId is bbbRdYRNJbaMXUVMXTcB, XPassword is vvVYaRdNrLacWXJObA);

Ecritures:

SQL SELECT *

FROM ACHATS.dbo."ECRITURES"

Where (EC_No > $(Maxpiece));

rubenmarin

Your original post calls that field 'Maxpiece', not 'MaxNo'