Help with "empty()"

Поиск
Список
Период
Сортировка
От Alan Wayne
Тема Help with "empty()"
Дата
Msg-id 20020524035725.69969.qmail@web21210.mail.yahoo.com
обсуждение исходный текст
Ответы Re: Help with "empty()"  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-general
Hi!

In doing table validation, I have often used the
foxpro function "empty()" which returns .t. if the
enclosed entity is empty. i.e., if boolean .f. then
empty = .t.. If number 0, then empty = .t., and if a
blank string, then empty = .t.

I didn't see anyother way to mimic this behavior then
what I wrote below, is there a better way????

Please help, suggestions are appreciated!
Cheers,
ajw

    CREATE FUNCTION zzipcode_validate_fields() RETURNS
opaque AS '
        BEGIN
            IF NEW.izipcode ISNULL THEN
                RAISE EXCEPTION ''zipcode is null.'' ;
            ELSE
                IF char_length( trim(both from NEW.izipcode)) < 9
THEN
                    RAISE EXCEPTION ''zipcode less-then 9-digits.'' ;
                END IF;
            END IF;

            IF NEW.cstate ISNULL THEN
                RAISE EXCEPTION ''state is null.'' ;
            ELSE
                IF char_length( trim(both from NEW.cstate))=0 THEN
                    RAISE EXCEPTION ''state is empty string.'';
                END IF;
            END IF;

            IF NEW.ccity ISNULL THEN
                RAISE EXCEPTION ''city is null.'';
            ELSE
                IF char_length( trim(both from NEW.ccity)) = 0
THEN
                    RAISE EXCEPTION ''city is empty string.'' ;
                END IF;
            END IF;

            NEW.cstate := upper(NEW.cstate);
            NEW.ccity := upper(NEW.ccity);
            RETURN NEW;
            END;
    'LANGUAGE 'plpgsql';

    CREATE TRIGGER zzipcode_validate BEFORE INSERT OR
UPDATE ON zzipcode
        FOR EACH ROW EXECUTE PROCEDURE
zzipcode_validate_fields();


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

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

Предыдущее
От: "Glen Parker"
Дата:
Сообщение: Pg_dump and huge OID's
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Help with "empty()"