Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khfhX-0002JL-R2 for pgsql-general@arkaria.postgresql.org; Tue, 24 Nov 2020 21:18:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khfhW-0006nC-PL for pgsql-general@arkaria.postgresql.org; Tue, 24 Nov 2020 21:18:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khfhW-0006n4-IL for pgsql-general@lists.postgresql.org; Tue, 24 Nov 2020 21:18:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khfhU-0005HA-Jr for pgsql-general@postgresql.org; Tue, 24 Nov 2020 21:18:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0AOLIBGI310538; Tue, 24 Nov 2020 16:18:11 -0500 From: Tom Lane To: Dave Greeko cc: "David G. Johnston" , pgsql-general Subject: Re: libpq Prepared Statement with dynamic IN operator In-reply-to: <486897627.767571.1606252454106@mail.yahoo.com> References: <160624463958.2014.4816164987028270278@malur.postgresql.org> <418457940.732204.1606245243551@mail.yahoo.com> <486897627.767571.1606252454106@mail.yahoo.com> Comments: In-reply-to Dave Greeko message dated "Tue, 24 Nov 2020 21:14:14 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <310536.1606252691.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 24 Nov 2020 16:18:11 -0500 Message-ID: <310537.1606252691@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dave Greeko writes: > I tried both and I am getting syntax error. > char *query=3D"select codec_id,fs_name,pt from codec_defs where pt =3D A= NY(string_to_array(?, ','))"; > OR > char *query=3D"select codec_id,fs_name,pt from codec_defs where pt =3D A= NY(?::text)"; > PGresult *res=3DPQprepare(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 =3D ANY($1::text[])". regards, tom lane