| From: | hubert depesz lubaczewski <depesz(at)depesz(dot)pl> | 
|---|---|
| To: | al_nunes(at)ciclotecnologia(dot)com(dot)br | 
| Cc: | pgsql-docs(at)postgresql(dot)org | 
| Subject: | Re: Trigger Documentation | 
| Date: | 2001-06-10 07:35:44 | 
| Message-ID: | 20010610093544.14c48d82.depesz@depesz.pl | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-docs | 
On Fri, 8 Jun 2001 11:55:08 -0300 (BRT)
al_nunes(at)ciclotecnologia(dot)com(dot)br wrote:
> What I need to do now is very simple, I want to make a trigger that
check
> if some text field is null. If it is, I want to record something on
> it. What I was trying (unsuccessfully):
> CREATE FUNCTION ins_ip() RETURNS OPAQUE AS '
> BEGIN
>  IF NEW.<field> ISNULL THEN
>   NEW.<field> := "something";
>    RETURN NEW;
> END;
you're missing two things.
1st. there should be end if
2nd. is should be NEW.<field> := ''something'';
btw. it's better to do it with "DEFAULT" statement in create table.
depesz
-- 
hubert depesz lubaczewski                          http://www.depesz.pl/
------------------------------------------------------------------------
     najwspanialszą rzeczą jaką dało nam nowoczesne społeczeństwo,
      jest niesamowita wręcz łatwość unikania kontaktów z nim ...
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Anthony Dye | 2001-06-12 16:06:29 | 404 | 
| Previous Message | Bruce Momjian | 2001-06-10 03:47:13 | Re: Update needed for documentation |