RE: trouble with triggers - Mailing list pgsql-general

From Robert Treat
Subject RE: trouble with triggers
Date
Msg-id AMENJOLMNKAEOIGHHILBAELLCBAA.robertt@auctionsolutions.com
Whole thread Raw
In response to Re: trouble with triggers  (Fran Fabrizio <ffabrizio@mmrd.com>)
Responses RE: trouble with triggers  ("Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu>)
List pgsql-general
> >
> > CREATE TRIGGER formatname BEFORE update OR insert ON mytable
> FOR EACH row
> > EXECUTE PROCEDURE lower(name);
>
> The way I understand it, you can't just use any function as a
> trigger.  It has
> to have a return type of opaque.  I see that you are basically trying to
> convert to lowercase before inserting, but I'm pretty sure you'd
> have to define
> your own pgplsql function for the trigger which uses the special
> variable 'new'
> to access the incoming row.  Your function can call lower() of course.
>
> Others here can probably give you more details.
>
> -Fran

Does the function have to be written using the plpgsql language? I tried
writing my own function using just sql and it gave the same error message. I
did trying writing the function using pgplsql:

CREATE FUNCTION formatmyname() RETURNS opaque AS '
BEGIN
new.name := lower(new.name);
RETURN NEW;
END;
' LANGAUGE 'pgplsql';

but got back a message that pgplsql was an unrecognized langauge, so I'm
looking for a non pgplsql solution. If I'm spinning my wheels I will work on
getting pgplsql working, but I'm hopeing to do it with a simpler approach.

robert


pgsql-general by date:

Previous
From: "Richard Huxton"
Date:
Subject: Re: trouble with triggers
Next
From: "Ben-Nes Michael"
Date:
Subject: Re: VACUUM ANALYZE