Re: writing a Delete trigger on a table for cascading effect
From: Eric Sabine (mopar41_at_hyotyt_mail_nounderscores.com)
Date: 07/23/04
- Next message: Tim Cowan: "Re: Help with trigger cursor"
- Previous message: Rohtash Kapoor: "Re: multi count"
- In reply to: Rodger: "Re: writing a Delete trigger on a table for cascading effect"
- Next in thread: Joe Celko: "Re: writing a Delete trigger on a table for cascading effect"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Jul 2004 10:30:55 -0400
"But our developers out here do not beleive in primary key and foreign key
constraints so putting constraints on tables is ruled out"
LOL
OK, use this
create trigger on TABLENAME for delete -- note the inclusion of delete
only, not insert or update.
...
You get a trigger that fires on a delete only.
hth
Eric
Rodger wrote:
> Thanks Eric
>
> But our developers out here do not beleive in primary key and foreign
> key constraints so putting constraints on tables is ruled out, if you
> have a small code for delete trigger where it just picks up the row
> deleted and not the row updated, because in case of update the
> deleted table also has a value which is i dont want
>
> thanks
>
>
>
> "Eric Sabine" wrote:
>
>> Yes a trigger would work. You would query on the virtual table
>> called DELETED from within the trigger. But better is to use
>> referential integrity and allow cascading deletes. For example some
>> air code
>>
>>
>> create table parent( id int identity primary key)
>> create table child (col1 int not null, col2 int not null constraint
>> FK_CHILD_PARENT_ID foreign key references parent ( id ) on update no
>> action on delete cascade)
>>
>> hth
>> Eric
>>
>>
>> Rodger wrote:
>>> Hi Guys
>>>
>>> I want to write a delete trigger on a table which will delete rows
>>> on a second table, I have written triggers for insert and update
>>> but not tried delete, would appreciate if somebody can give me a
>>> small sample code for any two tables. for delete operation
>>>
>>> Thanks
- Next message: Tim Cowan: "Re: Help with trigger cursor"
- Previous message: Rohtash Kapoor: "Re: multi count"
- In reply to: Rodger: "Re: writing a Delete trigger on a table for cascading effect"
- Next in thread: Joe Celko: "Re: writing a Delete trigger on a table for cascading effect"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|