timestamp literal out of line - Mailing list pgsql-general

From Martijn van Oosterhout
Subject timestamp literal out of line
Date
Msg-id 20100307123229.GB22191@svana.org
Whole thread Raw
Responses Re: timestamp literal out of line  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Version: 8.3.9

I was surprised when I came across the following while changing some
code to send parameters out of line (to avoid interpolation).

postgres=# prepare test1 as select timestamp '2009-01-01';
PREPARE
postgres=# prepare test2 as select timestamp $1;
ERROR:  syntax error at or near "$1"

The workaround is simple, use a cast instead, but is there a particular
reason why you can't use a parameter there?

This does work, oddly enough.

postgres=# prepare test2 as select timestamp '2009-01-01' at time zone $1;
PREPARE

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Chris
Date:
Subject: Re: XML Index again
Next
From: Dimitri Fontaine
Date:
Subject: Re: accessing the words in a full text index