RE: Rule/currval() issue - Mailing list pgsql-sql

From Creager, Robert S
Subject RE: Rule/currval() issue
Date
Msg-id 10FE17AD5F7ED31188CE002048406DE8514D00@lsv-msg06.stortek.com
Whole thread Raw
In response to Rule/currval() issue  (Tim Perdue <tim@perdue.net>)
Responses Re: Rule/currval() issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Tom,

You indicate trigger, rather than rule.  Going by Momjian's book, he
indicates that rules are "...ideal for when the action affects other
tables."  Can you clarify why you would use a trigger for this?  I'm asking
because I have no clue how to use rules or triggers, but need one or the
other to modify a second table on inserts/deletes to the first table.  I'd
like to make the best choice first if possible.

Thanks,
Rob

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Wednesday, March 14, 2001 11:09 AM
> To: Tim Perdue
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Rule/currval() issue 
> 
> 
> Tim Perdue <tim@perdue.net> writes:
> > This is related to the plpgsql project I was working on 
> this morning. I'm
> > trying to create a rule, so that when a row is inserted 
> into a certain table,
> > we also create a row over in a "counter table". The problem 
> lies in getting
> > the primary key value (from the sequence) so it can be 
> inserted in that
> > related table.
> 
> You probably should be using a trigger, not a rule at all.
> 
>             regards, tom lane
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to 
> majordomo@postgresql.org)
> 


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Rule/currval() issue
Next
From: Tom Lane
Date:
Subject: Re: Rule/currval() issue