Re: Extended Query: Parse Command: syntax? - Mailing list pgsql-novice

From Tom Lane
Subject Re: Extended Query: Parse Command: syntax?
Date
Msg-id 2618.1089432857@sss.pgh.pa.us
Whole thread Raw
In response to Re: Extended Query: Parse Command: syntax?  ("M. Bastin" <marcbastin@mindspring.com>)
List pgsql-novice
"M. Bastin" <marcbastin@mindspring.com> writes:
> At 4:26 PM +0200 7/8/04, M. Bastin wrote:
>> When you send the query to be parsed I presume you must somehow tell
>> which elements of it are parameters.  How do you do this?
>> e.g.:   SELECT name, phone FROM friends WHERE age > 25;
>> How would I write this if "name" and "25" must be parameters?

    SELECT name, phone FROM friends WHERE $1 > $2;

>> Or if
>> the operator ">" should be a parameter or modifiable in another way?

You cannot make an operator a parameter.  It's not very clear what it
would mean to prepare a query in which some operators remain unknown ---
certainly the planner could not produce any useful plan for it.

> Can "age > 25" as a whole be a parameter?

Only if you are prepared to supply a boolean value for it at Bind time.

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: table inheritance and polymorphic functions
Next
From: Tom Lane
Date:
Subject: Re: array in postgre