From: Tom Lane <tgl@sss.pgh.pa.us>
To: Paul Forgey <paulf@aphrodite.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PQexecParams not seeing params
Date: Tue, 27 Jun 2006 23:21:10 -0400
Message-ID: <11021.1151464870@sss.pgh.pa.us> (raw)
In-Reply-To: <862A81E4-B946-45E8-B3AF-81F6BD2BC623@aphrodite.com>
References: <862A81E4-B946-45E8-B3AF-81F6BD2BC623@aphrodite.com>
Paul Forgey <paulf@aphrodite.com> 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
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, paulf@aphrodite.com
Subject: Re: PQexecParams not seeing params
In-Reply-To: <11021.1151464870@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