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

Re: Extended Query: Parse Command: syntax?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "M(dot) Bastin" <marcbastin(at)mindspring(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Extended Query: Parse Command: syntax?
Date: 2004-07-10 04:14:17
Message-ID: 2618.1089432857@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
"M. Bastin" <marcbastin(at)mindspring(dot)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

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2004-07-10 04:29:05
Subject: Re: array in postgre
Previous:From: Tom LaneDate: 2004-07-10 03:16:26
Subject: Re: table inheritance and polymorphic functions

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