| From: | al_nunes(at)ciclotecnologia(dot)com(dot)br | 
|---|---|
| To: | pgsql-docs(at)postgresql(dot)org | 
| Subject: | Trigger Documentation | 
| Date: | 2001-06-08 14:55:08 | 
| Message-ID: | Pine.LNX.4.21.0106081145560.8814-100000@pinguim.ciclotecnologia.com.br | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-docs | 
Hi,
I could not find enough examples about the usage of triggers with
PostgreSQL. Searching in the list files, I found out that there are some
examples in contrib/spi/ directory, but this examples scared me a little
because all the triggers are written in C.
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;
' LANGUAGE 'plpgsql';
CREATE TRIGGER tr_ponto_ins BEFORE INSERT OR UPDATE ON ponto
    FOR EACH ROW EXECUTE PROCEDURE ins_ip();
Ie tryed to put something beetwen quotes, double-quotes, nothing
worked. Will I have to write an enormous trigger in C?
Regards,
Alvaro Nunes Melo
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vince Vielhaber | 2001-06-08 15:01:23 | Re: Developer's Bios | 
| Previous Message | Pierce Tyler | 2001-06-08 14:30:59 | Developer's Bios |