Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David Johnston
> > > On Wed, Jan 21, 2015 at 4:09 PM, Bryn Jeffries < > bryn.jeffr...@sydney.edu.au> wrote: > >> >> Maybe what we need in ODBC libs and the like is a "protected >> statement" that follows the same construction as a prepared statement but >> additionally checks catalogs to validate identifiers. >>

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Adrian Klaver
On 01/21/2015 03:09 PM, Bryn Jeffries wrote: Paul Jungwirth wrote I'm not sure how to make a prepared statement that lets you name a column when you execute it. Maybe someone else can chime in if that's possible. David J. responded You cannot. By definition parameters, in this context, are v

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David Johnston
On Wed, Jan 21, 2015 at 4:09 PM, Bryn Jeffries wrote: > Paul Jungwirth wrote > > I'm not sure how to make a prepared statement that lets you name a > > column when you execute it. Maybe someone else can chime in if that's > > possible. > > David J. responded > > You cannot. By definition paramet

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
Paul Jungwirth wrote > I'm not sure how to make a prepared statement that lets you name a > column when you execute it. Maybe someone else can chime in if that's > possible. David J. responded > You cannot. By definition parameters, in this context, are values - not > identifiers. > [...] > In

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
@postgresql.org" Subject: [GENERAL] ORDER BY in prepared statements Date: Thu, Jan 22, 2015 08:18 On 01/21/2015 12:51 PM, Bryn Jeffries wrote: > In a number of places on the web I've seen it claimed that ordering can > be set via prepared statements. Can you give a link t

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread David G Johnston
Paul Jungwirth wrote >> In a number of places on the web I've seen it claimed that ordering can >> be >> set via prepared statements. >> ... >> sandbox=# PREPARE testplan(text) AS >> SELECT * FROM test ORDER BY $1; >> >> But the output is not what one would expect: >> >> sandbox=# EXECUTE testplan(

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Adrian Klaver
On 01/21/2015 12:51 PM, Bryn Jeffries wrote: In a number of places on the web I've seen it claimed that ordering can be set via prepared statements. Can you give a link to one of those examples? Many thanks, Bryn -- Adrian Klaver adrian.kla...@aklaver.com -- Sent via pgsql-general mail

Re: [GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Paul Jungwirth
> In a number of places on the web I've seen it claimed that ordering can be > set via prepared statements. > ... > sandbox=# PREPARE testplan(text) AS > SELECT * FROM test ORDER BY $1; > > But the output is not what one would expect: > > sandbox=# EXECUTE testplan('gender'); > ... > As opposed to:

[GENERAL] ORDER BY in prepared statements

2015-01-21 Thread Bryn Jeffries
In a number of places on the web I've seen it claimed that ordering can be set via prepared statements. Indeed, the expected syntax is accepted on my 9.3 server without errors: sandbox=# CREATE TABLE test ( id serial PRIMARY KEY, gender char ); sandbox=# INSERT INTO test(gender) VALUES('m') VA