Re: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When Using Substitution Parameter

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When Using Substitution Parameter
Дата
Msg-id 17552.1524612121@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException When UsingSubstitution Parameter  (PG Bug reporting form <noreply@postgresql.org>)
Ответы RE: BUG #15171: JDBC TIMESTAMP WITH TIME ZONE PSQLException WhenUsing Substitution Parameter  ("Carlsen, Len" <len.carlsen@ubc.ca>)
Список pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> Executing this query works fine: 'SELECT TIMESTAMP WITH TIME ZONE
> '2018-04-17 12:00:00.0-07'"
> But executing query "SELECT TIMESTAMP WITH TIME ZONE ?" with a substitution
> parameter results in a PSQLException syntax error.

Yes.  A parameter symbol is not a syntactic equivalent to a
string literal; it's more nearly like a variable.  You can't say
"typename variable" either.  You need to write it like a cast,
ie "variable::typename", or "CAST(variable AS typename)" if you
want to be pedantically standards-compliant.  So what you want is
"SELECT ?::TIMESTAMP WITH TIME ZONE".

(Allowing the non-orthogonal, non-extensible syntax "typename
string-literal" was not one of the SQL committee's better decisions
IMV.  We're stuck with supporting it, but I'd suggest avoiding it in
favor of cast-like notation, which works in a much wider variety of
cases.)

            regards, tom lane


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15170: PQtransactionStatus returns ACTIVE after Empty Commit
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15172: Postgresql ts_headline with <-> operator does nothighlight text properly