How to pass a list of values to an IN operator?

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
shmorsecode
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 30.11.2023, 18:55

How to pass a list of values to an IN operator?

Post by shmorsecode »

Hi everyone! This is my first post.

I've been wondering how would you pass a list of values given a query like this?

Code: Select all

SELECT * FROM MyTable T WHERE T.ID IN (:id_list)
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: How to pass a list of values to an IN operator?

Post by aehimself »

Hello and welcome to the forum!

As far as I recall I saw array type in parameter values but I'm not sure if any protocols acutally support that. You can give that a try, that would be the best soltuion.
What should work however is multiple parameters, like

SELECT * FROM MyTable WHERE MyField IN (:pParam1, :pParam2, :pParam3 [...] )
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply