From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Sven W <sven(at)dmv(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: pl/pgsql FOUND variables and RULES |
Date: | 2009-06-01 22:48:58 |
Message-ID: | 25825.1243896538@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Sven W <sven(at)dmv(dot)com> writes:
> I have a volatile function (trigger) that gathers NEW.*, parses them, then inserts a
> subset of values into a different table.
> The table is set up as an inherited table where the parent table has a RULE :
> CREATE RULE myrule AS ON INSERT TO mytable WHERE ( myfield >= 100 and myfield < 200)
> DO INSTEAD
> INSERT INTO mytable_100 (field1,field2,field3,myfield) VALUES
> (NEW.field1,NEW.field2, NEW.field3, NEW.myfield);
> Now when the trigger fires the insert does happen and ends up in mytable_100 but the
> FOUND variable is not set (since technically 0 rows got inserted into mytable). Is
> there a proper way to set up rules such that the FOUND variable is set within
> pl/pgsql upon a successful insert (via the rule) or how can I check for a successful
> insert?
On the whole, you'd be a lot better off letting the trigger function
handle the redirection into the proper child table, I'd think. Using
both a trigger and a rule seems like it mainly gives you the worst of
both worlds.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Mason Hale | 2009-06-01 23:13:31 | waiting for ExclusiveLock on extension of relation |
Previous Message | Sven W | 2009-06-01 22:29:31 | pl/pgsql FOUND variables and RULES |