From: Dave Greeko <davegreeko@yahoo.com>
To: pgsql-general@postgresql.org
Subject: libpq Prepared Statement with dynamic IN operator
Date: Tue, 24 Nov 2020 19:14:03 +0000 (UTC)
Message-ID: <418457940.732204.1606245243551@mail.yahoo.com> (raw)
In-Reply-To: <160624463958.2014.4816164987028270278@malur.postgresql.org>
References: <160624463958.2014.4816164987028270278@malur.postgresql.org>
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 from codecs where tag IN (‘G729’,’GSM’);
The number of elements to filter for with this particular example is 2 but this varies at runtime (between 1 to 127 elements).
I would like to know what’s the proper syntax of the (char *query) parameter when calling the PQprepare() function.
I tried “select payload_id,ptime,frequency from codecs where tag=ANY(?)” but failed
Regards,
Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: davegreeko@yahoo.com
Subject: Re: libpq Prepared Statement with dynamic IN operator
In-Reply-To: <418457940.732204.1606245243551@mail.yahoo.com>
References: <160624463958.2014.4816164987028270278@malur.postgresql.org> <418457940.732204.1606245243551@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox