How to use a variable as a list

Stimulsoft Dashboards.WEB discussion
Post Reply
jlorue
Posts: 126
Joined: Thu Apr 15, 2021 6:33 pm

How to use a variable as a list

Post 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
Max Shamanov
Posts: 768
Joined: Tue Sep 07, 2021 10:11 am

Re: How to use a variable as a list

Post 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.
jlorue
Posts: 126
Joined: Thu Apr 15, 2021 6:33 pm

Re: How to use a variable as a list

Post 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.
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: How to use a variable as a list

Post by Lech Kulikowski »

Hello,

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

Thank you.
Post Reply