pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Greeko <davegreeko@yahoo.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: libpq Prepared Statement with dynamic IN operator
Date: Tue, 24 Nov 2020 16:18:11 -0500
Message-ID: <310537.1606252691@sss.pgh.pa.us> (raw)
In-Reply-To: <486897627.767571.1606252454106@mail.yahoo.com>
References: <160624463958.2014.4816164987028270278@malur.postgresql.org>
	<418457940.732204.1606245243551@mail.yahoo.com>
	<CAKFQuwZatW8rvCq6FbWnEkqqWzYNKWyt24mUpTSQNExUtruyrQ@mail.gmail.com>
	<486897627.767571.1606252454106@mail.yahoo.com>

Dave Greeko <davegreeko@yahoo.com> 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,"codecs",query,1,NULL);

Well, your first problem is that "?" is not the parameter symbol
understood by libpq+backend.  Try "$1".  The other problem,
at least for the second version of that, is that you want to be
passing a text array not a single text value --- so it needs to
look more like "where pt = ANY($1::text[])".

			regards, tom lane





view thread (7+ messages)  latest in thread

Message-ID: <310537.1606252691@sss.pgh.pa.us>
Permalink:  ../310537.1606252691@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/310537.1606252691@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, davegreeko@yahoo.com, david.g.johnston@gmail.com
  Subject: Re: libpq Prepared Statement with dynamic IN operator
  In-Reply-To: <310537.1606252691@sss.pgh.pa.us>
  References: <160624463958.2014.4816164987028270278@malur.postgresql.org> <418457940.732204.1606245243551@mail.yahoo.com> <CAKFQuwZatW8rvCq6FbWnEkqqWzYNKWyt24mUpTSQNExUtruyrQ@mail.gmail.com> <486897627.767571.1606252454106@mail.yahoo.com> <310537.1606252691@sss.pgh.pa.us>

* 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