pg.ddx.io pgsql-interfaces@postgresql.org mailing list archivehelp / color / mirror / Atom feed
PQexecParams not seeing params 2+ messages / 2 participants [nested] [flat]
* PQexecParams not seeing params @ 2006-06-28 00:29 Paul Forgey <paulf@aphrodite.com> 2006-06-28 03:21 ` Re: PQexecParams not seeing params Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: Paul Forgey @ 2006-06-28 00:29 UTC (permalink / raw) To: pgsql-interfaces I am using the libpq client library from 8.1.4 in an application that is intended to be compatible with databases hosted on both 7.4 and 8.1. 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". The documentation says the parameters are referred to in the command string as $n. Is this not always the case? What am I missing? since PQexecParams was present in 7.4 I am assuming the server has the sufficient protocol level to support it. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PQexecParams not seeing params 2006-06-28 00:29 PQexecParams not seeing params Paul Forgey <paulf@aphrodite.com> @ 2006-06-28 03:21 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2006-06-28 03:21 UTC (permalink / raw) To: Paul Forgey <paulf@aphrodite.com>; +Cc: pgsql-interfaces 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 ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-06-28 03:21 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2006-06-28 00:29 PQexecParams not seeing params Paul Forgey <paulf@aphrodite.com> 2006-06-28 03:21 ` Tom Lane <tgl@sss.pgh.pa.us>
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