Skip to main content
Known Participant
Oct 1, 2021 6:15 PM UTC
Question

Problem setting SQL sentence "SELECT... IN " in Query database

Hi there,

I have problem setting up the SQL sentence "SELECT .... IN " in query database smart service. 

if I directly writing "SELECT .... IN ('1234','5678')"  in the SQL Statement, it will work.

if I have create a process variable to be the string '1234','5678', then put the following sentence 

SELECT .... IN (ac!str)       and assign the process variable to this ac!str, it will not work.

I dont know what's the problem here, as I can't hard coded in the SQL sentence, the string need to be dynamic.

Can anyone be able to help?

regards,

Lin

5 replies

Participating Frequently
Oct 1, 2021 6:51 PM UTC

can you paste the config in data tab of query rule smart service..is it with multiple values?

csteward
Brainy
Oct 1, 2021 7:04 PM UTC

What type of database are you using?  In Oracle, we work around this by utilizing INSTR() such as:

SELECT ...
WHERE INSTR(ac!list, ',' || table.column || ',') > 0

The ac! value in your Data Inputs tab is then defined as:

="," & joinarray(pv!list, ",") & ","

Where pv!list is the multiple variable that you are looking to search on.

linp0001Author
Known Participant
Oct 1, 2021 7:22 PM UTC

Thanks Chris. my database is SQL server, the INSTR is not working. 

csteward
Brainy
Oct 1, 2021 7:27 PM UTC

Yes, INSTR() is an Oracle-only function.  For MSSQL Server, you will likely be switching to CHARINDEX().