Re: 'true'::TEXT::BOOLEAN

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: 'true'::TEXT::BOOLEAN
Дата
Msg-id 3DCEDE55-9D4A-4F4E-8907-ADCC058A3398@myrealbox.com
обсуждение исходный текст
Ответ на Re: 'true'::TEXT::BOOLEAN  (Markus Bertheau ☭ <twanger@bluetwanger.de>)
Ответы Re: 'true'::TEXT::BOOLEAN
Список pgsql-sql
On Jun 3, 2005, at 8:52 PM, Markus Bertheau ☭ wrote:

> And I can't call it with a TEXT variable, because casting from TEXT to
> BOOLEAN isn't possible.


I'd be surprised if there weren't a some way to coerce the cast from
text to boolean, but you might want to just make a simple convenience
function in the interim:

test=# create or replace function text2bool (text)    returns boolean language sql as $$
select case    when lower($1) = 'true'        then true    else false    end;    $$;
CREATE FUNCTION

test=# select text2bool('true');
text2bool
-----------
t
(1 row)

test=# select text2bool('false');
text2bool
-----------
f
(1 row)


Just an idea.

Michael Glaesemann
grzm myrealbox com



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

Предыдущее
От: Markus Bertheau ☭
Дата:
Сообщение: Re: 'true'::TEXT::BOOLEAN
Следующее
От: Markus Bertheau ☭
Дата:
Сообщение: Re: 'true'::TEXT::BOOLEAN