X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 569489FA3CD for ; Wed, 28 Jun 2006 00:21:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 49351-09 for ; Wed, 28 Jun 2006 00:21:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B3FF99F9DCC for ; Wed, 28 Jun 2006 00:21:15 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k5S3LAXq011022; Tue, 27 Jun 2006 23:21:10 -0400 (EDT) To: Paul Forgey cc: pgsql-interfaces@postgresql.org Subject: Re: PQexecParams not seeing params In-reply-to: <862A81E4-B946-45E8-B3AF-81F6BD2BC623@aphrodite.com> References: <862A81E4-B946-45E8-B3AF-81F6BD2BC623@aphrodite.com> Comments: In-reply-to Paul Forgey message dated "Tue, 27 Jun 2006 17:29:46 -0700" Date: Tue, 27 Jun 2006 23:21:10 -0400 Message-ID: <11021.1151464870@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/38 X-Sequence-Number: 6179 Paul Forgey writes: > At least when talking to a 7.4 server, the following statement: > res = PQexecParams (pgc, "FETCH 100 $1", 1, NULL, paramValues, NULL, > NULL, 1) > results in "syntax error at or near $1 at character 11". Well, that would fail regardless because the FETCH syntax requires FROM or IN between the count and the cursor name; but your big problem is that parameter symbols can only stand for data values. Not table names, not field names, not (as in this case) cursor names. This must be so because the backend is supposed to be able to infer the meaning of the query --- at least to the extent of being able to determine the result columns, for instance --- before it has the actual values of the parameters. You might want to consider assembling the FETCH command as a single string, along the lines of sprintf(buffer, "FETCH 100 FROM %s", cname) and sending that. SQL parameters won't help. regards, tom lane