Skip site navigation (1) Skip section navigation (2)

Re: PQexecParams not seeing params

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Forgey <paulf(at)aphrodite(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PQexecParams not seeing params
Date: 2006-06-28 03:21:10
Message-ID: 11021.1151464870@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
Paul Forgey <paulf(at)aphrodite(dot)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

In response to

pgsql-interfaces by date

Next:From: Rodrigo SakaiDate: 2006-06-28 14:49:56
Subject: Creating a new type
Previous:From: Paul ForgeyDate: 2006-06-28 00:29:46
Subject: PQexecParams not seeing params

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group