xsharp.eu • ADS SQL statement to check in array
Page 1 of 1

ADS SQL statement to check in array

Posted: Sun Sep 12, 2021 8:16 am
by ic2
In ADS I can select

cQuery:="Select * from Mydbf d where d.somedate>='"+Date2SQLDate(dFrom)+"' AND d.somedate<='"+Date2SQLDate(dTo)+"' "
cQuery+="AND d.relation='"+cRel+"' "

in which case I get records within the given date range for this (1) relation (e.g. client) only.
I however do have a selection of relation keys in an array aRelations. But this won't work as 2nd line:

cQuery+="AND ascan(SELF:aRelations,d.relations)<>0"
Is there a way to achieve that?

Dick

ADS SQL statement to check in array

Posted: Mon Sep 13, 2021 3:06 am
by wriedmann
Hi Dick,
I would transform the content of self:aRelations to a SQL array and write:
cQuery += " and d.relations in ( x, y, z, ... )"
For such uses I have a function Array2SQLList().
Wolfgang

ADS SQL statement to check in array

Posted: Mon Sep 13, 2021 9:31 am
by ic2
Hello Wolfgang,

Yes, that work, thanks a lot! I wasn't aware of SQL arrays until your reply.

Dick