Re: timestamp literal out of line

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: timestamp literal out of line
Date: 2010-03-07 15:34:31
Message-ID: 15864.1267976071@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> 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?

"timestamp foo" is legitimate syntax only when foo is a string literal.
It is not a general cast syntax. We wouldn't even support it at all,
because it's so syntactically messy and inextensible, except that the
SQL standard requires it for literals of certain datatypes.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message zxo102 ouyang 2010-03-07 15:39:03 should I reindex the table of more than 10 millions rows regularly when more data are inserted?
Previous Message Dimitri Fontaine 2010-03-07 14:21:31 Re: accessing the words in a full text index