Re: Insert rule and seqences

From: Bo Lorentsen <bl(at)netgroup(dot)dk>
To: Jochem van Dieten <jochemd(at)oli(dot)tudelft(dot)nl>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Insert rule and seqences
Date: 2001-09-04 08:14:46
Message-ID: 3B948D76.53D1744A@netgroup.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jochem van Dieten wrote:

> I wouldn't use a RULE but a TRIGGER. Something like the one below
> (please check syntax ;) ).

Thanks, this works perfect for me now.

Is it correct that this is not possible to do when using pure "language 'sql'"
? As this language type can't refere to the "new" attribute.

> CREATE TRIGGER tr_insert_on_a AFTER INSERT OR UPDATE ON A
> FOR EACH ROW EXECUTE PROCEDURE fn_insert_on_a();
>
> CREATE function fn_insert_on_a() RETURNS OPAQUE AS '
> BEGIN
> INSERT INTO B name, a_ref VALUES(NEW.name, NEW.id);
> END;
> ' LANGUAGE 'plpgsql';

You only needed the "RETURN new;" line and this was perfect, thanks.

/BL

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jason Tan 2001-09-04 09:19:04 Re: pl/pgsql recursion/arrays (fwd)
Previous Message Bo Lorentsen 2001-09-04 08:00:43 Re: pl/pgsql recursion/arrays (fwd)