From: "Robert Treat" <robertt@auctionsolutions.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