Re: cannot cast type boolean to text?

Поиск
Список
Период
Сортировка
От Shoaib Mir
Тема Re: cannot cast type boolean to text?
Дата
Msg-id bf54be870706141143m7939f764sb829da2a14e038bd@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cannot cast type boolean to text?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
This should help:

create or replace function bool_to_text (boolean)
    returns char
    strict
    language sql as '
    select case
        when $1 then \'t\'
        else \'f\'
        end;
    ';

create cast (boolean as char(1))
    with function bool_to_text(boolean)
    as implicit;

--
Shoaib Mir
EnterpriseDB (www.enterprisedb.com)

On 6/14/07, Tom Lane < tgl@sss.pgh.pa.us> wrote:
Brian Hurt < bhurt@janestcapital.com> writes:
>     SELECT true :: text;
> ERROR:  cannot cast type boolean to text

> I was wondering why this is so.

Because there's no pg_cast entry for this conversion.

There will be one in 8.3, but for older releases make your own with
CREATE CAST.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

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

Предыдущее
От: "Shoaib Mir"
Дата:
Сообщение: Re: cannot cast type boolean to text?
Следующее
От: nhrcommu@rochester.rr.com
Дата:
Сообщение: Formatting function, simple Q