timestamp literal out of line

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: timestamp literal out of line
Date: 2010-03-07 12:32:29
Message-ID: 20100307123229.GB22191@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2010-03-07 14:21:31 Re: accessing the words in a full text index
Previous Message Chris 2010-03-07 12:18:33 Re: XML Index again