Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread Dave Greeko
Many thanks for the clarification David. I wish there is a way without touching my input array but at least based on your feedback I can avoid the call to string_to_array call in the query. I tried it and it worked but I still have to permute the C array. Here is what I have working so far: c

Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread David G. Johnston
The convention here is to inline or bottom-post, not top-post. On Tue, Nov 24, 2020 at 3:47 PM Dave Greeko wrote: > I would really like to just pass an array of filters of type (const char* > const*) to PQexecPrepared's paramValues[] parameter instead of making it > some sort of csv string. > //

Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread Dave Greeko
I am sorry I used different query in my my last reply and yes you are correct Tom. Using the $1 worked and the back-end indeed prepared the statement successfully but this will force me to do some work on the input array that contains the dynamic elements to comply with string_to_array delimite

Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread Tom Lane
Dave Greeko writes: > I tried both and I am getting syntax error. > char *query="select codec_id,fs_name,pt from codec_defs where pt = > ANY(string_to_array(?, ','))"; > OR > char *query="select codec_id,fs_name,pt from codec_defs where pt = > ANY(?::text)"; > PGresult *res=PQprepare(conn,"cod

Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread Dave Greeko
Hi David, I tried both and I am getting syntax error. char *query="select codec_id,fs_name,pt from codec_defs where pt = ANY(string_to_array(?, ','))"; OR char *query="select codec_id,fs_name,pt from codec_defs where pt = ANY(?::text)"; PGresult *res=PQprepare(conn,"codecs",query,1,NULL); Da

Re: libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread David G. Johnston
On Tue, Nov 24, 2020 at 12:14 PM Dave Greeko wrote: > Dear All, > I am having a hard time figuring out how prepare and execute a Prepared > Statement with an "IN" operator in the WHERE clause using libpq. The total > elements that will be passed to IN operator is dynamic and varied at > runtime.

libpq Prepared Statement with dynamic IN operator

2020-11-24 Thread Dave Greeko
Dear All, I am having a hard time figuring out how prepare and execute a Prepared Statement with an "IN" operator in the WHERE clause using libpq. The total elements that will be passed to IN operator is dynamic and varied at runtime. here is an example query: select payload_id,ptime,frequency