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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewforum
Creator II
Creator II

Use of exists in the SQL in statement

I have field called f_Acct which contains around 1000 values before loading the FACT table from a database.

Load *,

where exists(f_Acct,ACCT);

SQL Select Column1,

           Column2,

           ACCT

From Account_Table;

Instead of using the exists in the Qlikview load statement I want make use of the same in the SQL Statement. As the SQL load all the data from the Account_Table and then we filters the values in the Preceding load using exists which having performance issue. Please help!

16 Replies
qlikviewforum
Creator II
Creator II
Author

If I pass the variable in the SQL without single quotes($(vList)) then it is not fetching any records. If I pass the single quotes ('$(vList)') then it is throwing error. Can you please help?

anbu1984
Master III
Master III

Error("string literal too long" means your string is more than 4000 chars. It seems all the accounts are clubbed into one string. Check the value of $(vList)

qlikviewforum
Creator II
Creator II
Author

It contains all the values with comma seperated. This is what should be passed into the SQL IN clause right?

vList='xyz','trt','rte','ete'

By the way should I pass single quotes while passing the variable in the SQL or not?

anbu1984
Master III
Master III

Yes

Not applicable

Hello,

You can try using exists() function instead of IN.

Load

     *;

Sq

select f_Acct_orig  from

YourTable i1

join

(select 408007421 as f_Acct union all

select 407039314 union all

select 409691748 union all

select 407741572 union all

select 605662536 union all

select 407773540  union all

select 407759193) i2 on i1.f_Acct_orig = i2.f_Acct

l

The best way to do this is as above. Transform your id's into select .... union all format...and then keep the variable with that value..and use like above.

Thanks.

Angad

qlikviewforum
Creator II
Creator II
Author

If I pass single quotes I am getting the below error. Please suggest

"string literal too long"

anbu1984
Master III
Master III

Try with few accounts say less than 10 in vList and check if you get the result.