in-list parameter as array (etc)

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mWaltari
Posts: 6
Joined: Thu 10 Jul 2014 09:18

in-list parameter as array (etc)

Post by mWaltari » Thu 09 Jan 2020 06:08

I've been thinking that something like this would make code way easier.

SELECT *
FROM TABLEA
WHERE
ID IN (:INPARAMETER)

could use it like

LQueryTableA.ParamByName('INPARAMETER').InParameter([1, 2, 3, 4, 5]);

(not .AsInArray etc because can't overload because values can come from different data types)

It should have few overloads depending where data is coming From. TStrings, TArray<T>, TList<T> at least.

Should take care of quotes and so. This would make code side way simpler and no need for own code to handle all this. Not sure which databases support this natively somehow, if not, could just modify SQL I think.

-Tee-

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: in-list parameter as array (etc)

Post by ViktorV » Fri 10 Jan 2020 08:49

To solve your task, you can use Macros. For example:
var
InConditione: string;
...
IBCQuery.SQL.Text := 'select * from tablea where ID in (&InCondition)';
InCondition := '1, 2, 3';
IBCQuery.MacroByName('InCondition').AsString := InCondition;
IBCQuery.Open;
You can learn more about Macros at: http://www.devart.com/ibdac/docs/work_macros.htm

Post Reply