Page 1 of 1

How to use a variable as a list

Posted: Thu Dec 22, 2022 12:09 pm
by jlorue
Hi,
I need to define a variable as a list of integers (eg: 2,4,7,11,15), so I can write a sql query with filter if a data field is within that list, as follows:

Select * from table1
where
field1 in variablelist

(I do not mean this the exact query, but just to give you the idea that I want to validate that the value of field1 is within those values of the list defined for the variable).

How can I do that?

Thanks,
Jose Luis

Re: How to use a variable as a list

Posted: Thu Dec 22, 2022 2:52 pm
by Max Shamanov
Hello,

Please try to use the following query:

Code: Select all

SELECT * FROM Table WHERE ID IN {(var1.Count == 0 ? "(0)" : "(" + var1.ToQueryString() +")" )}
Thank you.

Re: How to use a variable as a list

Posted: Fri Dec 23, 2022 11:33 am
by jlorue
Thanks Max, I'll try it and let you know in case of any doubt.

Beisdes that, is there any way to define a variable as a list and not to ask the user to select it?

Note: to define the list, I will need to pass the list a a parameter.

Re: How to use a variable as a list

Posted: Fri Dec 23, 2022 2:15 pm
by Lech Kulikowski
Hello,

Yes, you can define List variable from the code:
report.Dictionary.Variables["Variable1"] = new StiDialogInfo(...)

Thank you.