Re: libpq Prepared Statement with dynamic IN operator - Mailing list pgsql-general

From Tom Lane
Subject Re: libpq Prepared Statement with dynamic IN operator
Date
Msg-id 310537.1606252691@sss.pgh.pa.us
Whole thread Raw
In response to Re: libpq Prepared Statement with dynamic IN operator  (Dave Greeko <davegreeko@yahoo.com>)
Responses Re: libpq Prepared Statement with dynamic IN operator  (Dave Greeko <davegreeko@yahoo.com>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Dave Greeko
Date:
Subject: Re: libpq Prepared Statement with dynamic IN operator
Next
From: Dave Greeko
Date:
Subject: Re: libpq Prepared Statement with dynamic IN operator