| From: | "Richard Huxton" <dev(at)archonet(dot)com> | 
|---|---|
| To: | "Robert Treat" <robertt(at)auctionsolutions(dot)com>, <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: trouble with triggers | 
| Date: | 2001-07-17 15:32:06 | 
| Message-ID: | 001901c10ed5$a53c4d20$1001a8c0@archonet.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
From: "Robert Treat" <robertt(at)auctionsolutions(dot)com>
> CREATE TRIGGER formatname BEFORE update OR insert ON mytable FOR EACH row
> EXECUTE PROCEDURE lower(name);
> ERROR:  CreateTrigger: function lower() does not exist
>
> obviously this does exist, since I can do inserts/updates/selects using
> lower(). I have also tried creating my own version of a lower function but
> it gives me the same message.
>
> Am I missing something? This seems like it should be pretty
straightforward.
> tia,
You need a special function for triggers. It needs to return "opaque" type
and not take any parameters (in this case). Inside your new function you
will have something like:
BEGIN
  NEW.name := lower(NEW.name);
  RETURN NEW;
END;
Since you need to use NEW and OLD to affect what is happening during your
updates.
See the manuals for an example or http://techdocs.postgresql.org/ for
several.
- Richard Huxton
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ben-Nes Michael | 2001-07-17 15:33:36 | Re: VACUUM ANALYZE | 
| Previous Message | Jose Manuel Lorenzo Lopez | 2001-07-17 15:15:57 | Re: How to find out the weekday from a date??? |