Re: [GENERAL] regarding triggers

2006-01-12 Thread John McCawley
surabhi.ahuja wrote: but if i have "on delete cascade" constraint, in that case if i have a trigger which is fired in case delet happens on the table y. i have a table x, and table y has a foreign key with "on delete cascade" constraint, now i delete a row from x, will the trigger still

Re: [GENERAL] regarding triggers

2006-01-12 Thread surabhi.ahuja
Title: RE: [GENERAL] regarding triggers but if i have "on delete cascade" constraint, in that case if i have a trigger which is fired in case delet happens on the table y. i have a table x, and table y has a foreign key with  "on delete cascade" constraint, now i

Re: [GENERAL] regarding triggers

2006-01-10 Thread Harry Jackson
On 1/10/06, John McCawley <[EMAIL PROTECTED]> wrote: > Regarding the usefulness of triggers...I tend to stay away from them. I > like to keep my data in my database and my logic in my application. I > try to relegate triggers to very simple things like timestamping > records. i.e. things that I

Re: [GENERAL] regarding triggers

2006-01-10 Thread Tom Lane
John McCawley <[EMAIL PROTECTED]> writes: > Foreign keys do not cascade deletions. By default, no, but there is the CASCADE option ... regards, tom lane ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will

Re: [GENERAL] regarding triggers

2006-01-10 Thread Guy Rouillier
John McCawley wrote: > Foreign keys do not cascade deletions. They will if you specify "on delete cascade". -- Guy Rouillier ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail com

Re: [GENERAL] regarding triggers

2006-01-10 Thread Jaime Casanova
On 1/10/06, Jaime Casanova <[EMAIL PROTECTED]> wrote: > On 1/10/06, surabhi.ahuja <[EMAIL PROTECTED]> wrote: > > > > > > is there an advantage of using a trigger? when the same job can be performed > > by a stored procedure? > > > a trigger is actually a stored procedure... the advantage is that i

Re: [GENERAL] regarding triggers

2006-01-10 Thread Jaime Casanova
On 1/10/06, surabhi.ahuja <[EMAIL PROTECTED]> wrote: > > > is there an advantage of using a trigger? when the same job can be performed > by a stored procedure? > a trigger is actually a stored procedure... the advantage is that it's called automagically when an event happens... > one more questi

Re: [GENERAL] regarding triggers

2006-01-10 Thread John McCawley
Foreign keys do not cascade deletions. If table y references table x on column a, the attempt to delete records in x with dependent records in y will yield an error. So the answer to that question is no, your trigger won't get called because a) y doesn't get touched because that's not what fo