Re: [GENERAL] change null to ""

Поиск
Список
Период
Сортировка
От Teodor Cimpoesu
Тема Re: [GENERAL] change null to ""
Дата
Msg-id 37CC6BAF.7A40B175@digiro.net
обсуждение исходный текст
Ответ на change null to ""  ("amy cheng" <amycq@hotmail.com>)
Список pgsql-general
amy cheng wrote:
>
> hi, all experts there,
>
> it's me again :-)
oh well :)
> I'm studying the example in postgresql-6.5.1/src/pl/plpgsql/test.
> I have another question: why do we need to "Set backlink to empty string if
> NULL value given"? is it JUST a test, or, some reasons to
> do that in general?
Nope, it's just an example of "triggers".
You should also post the CREATE statement of PSlot,
does it have a "NOT NULL" constraint for backlink attribute?
if yes, you've got the answer (I would also have a look but
I'm on the other OS right now :> )

> -- ************************************************************
> -- * BEFORE INSERT or UPDATE on all slots with backlink
> -- *    - Set backlink to empty string if NULL value given
> -- ************************************************************
> create function tg_chkbacklink() returns opaque as '
> begin
>     if new.backlink isnull then
>         new.backlink := '''';
>     end if;
>     return new;
> end;
> ' language 'plpgsql';
>
> create trigger tg_chkbacklink before insert or update
>     on PSlot for each row execute procedure tg_chkbacklink();
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> ************

--
CIMPOESU Teodor, Web Programmer (h)
@ DIGICOM S.A. Bucharest, Romania
@ Internet, site development
@ teo@digiro.net, +(401)-330.47.28

official home page ~ http://www.digiro.net/
Internet web  page ~ http://internet.digiro.net/

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

Предыдущее
От: Chris Bitmead
Дата:
Сообщение: Re: [GENERAL] Prog to generate table structure ...
Следующее
От: Teodor Cimpoesu
Дата:
Сообщение: Re: [GENERAL] How to display user-defined functions?