RE: trouble with triggers

From: "Robert Treat" <robertt(at)auctionsolutions(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: RE: trouble with triggers
Date: 2001-07-17 15:39:54
Message-ID: AMENJOLMNKAEOIGHHILBAELLCBAA.robertt@auctionsolutions.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-07-17 15:45:27 Re: trouble with triggers
Previous Message Weiping He 2001-07-17 15:34:40 Re: [HACKERS] Translators wanted