Syntax Error for "boolean('value')" Type Casting

Поиск
Список
Период
Сортировка
От David Johnston
Тема Syntax Error for "boolean('value')" Type Casting
Дата
Msg-id 023601cc17eb$c76dd880$56498980$@yahoo.com
обсуждение исходный текст
Ответы Re: Syntax Error for "boolean('value')" Type Casting
Список pgsql-general

PostgreSQL 9.0.3, compiled by Visual C++ build 1500, 64-bit

 

The following intuitively valid statement fails:

 

SELECT boolean(‘true’)

 

>>SQL Error: ERROR:  syntax error at or near "("

>>LINE 1: SELECT boolean('true')

>>                      ^

 

The following work as expected:

 

SELECT bool(‘true’)

 

SELECT ‘true’::boolean

SELECT ‘true’::bool

 

SELECT bool ‘true’

SELECT boolean ‘true’

 

SELECT CAST('true' AS boolean)

SELECT CAST('true' AS bool)

 

While I’m here…is there any downside to using the “type(value)” form of casting versus other forms?  The main place I will be using them is in SQL Select statements stored in textual form with parameter placeholders.  The software I use for development allows parameters in the form of “:paramname” as opposed to the limited “?” so using the “::type” cast form is difficult.  The “CAST( value AS type)” is too verbose for my liking and the “type ‘true’” just looks wrong to my eyes – not a huge fan of function calls that do not use parenthesis.

 

A sample full query form would be:

 

SELECT * FROM table WHERE col1 = boolean(:value);

 

I can replace the “:value” with a “?” before passing it to JDBC (or with a hard-coded value within Java if so desired) and can use it as-is within PostgreSQL Maestro.

 

 

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

Предыдущее
От: Dan S
Дата:
Сообщение: Re: strange type name in information_schema
Следующее
От: Ben Chobot
Дата:
Сообщение: Re: understanding pg_locks