Casting

Поиск
Список
Период
Сортировка
От Nigel J. Andrews
Тема Casting
Дата
Msg-id Pine.LNX.4.21.0304081002330.24319-100000@ponder.fairway2k.co.uk
обсуждение исходный текст
Ответы Re: Casting  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general

I'm obviously missing something here but I don't know what. This is on 7.3.2.
When I use my cast I get:

mydb=> select cast('truE'::text as boolean);
WARNING:  Error occurred while executing PL/pgSQL function text_to_bool
WARNING:  line 4 at select into variables
ERROR:  CopyQuerySnapshot: no snapshot has been set

Any clues as to why that is?

The code is simplistic to say the least:


-- text_to_bool ()
--
-- Cast from text type to boolean.
--
CREATE OR REPLACE FUNCTION text_to_bool ( text )
    RETURNS boolean
    AS '
    DECLARE
        rv    boolean;
    BEGIN
        SELECT INTO rv
            CASE
                WHEN lower($1) = ''true''
                    OR lower($1) = ''t''
                    OR lower($1) = ''1''
                THEN
                    true
                WHEN lower($1) = ''false''
                    OR lower($1) = ''f''
                    OR lower($1) = ''0''
                THEN
                    false
                ELSE
                    NULL
                END;
        RETURN rv;
    END;
    '
    LANGUAGE 'plpgsql'
    STRICT
    IMMUTABLE;

CREATE CAST (text AS boolean) WITH FUNCTION text_to_bool ( text );


Thanks,

--
Nigel J. Andrews


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

Предыдущее
От: Jean-Christian Imbeault
Дата:
Сообщение: Re: Instalation problem
Следующее
От: Laurent Perez
Дата:
Сообщение: CVS doesn't compile initdb and other binaries