Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to write trigger for ON_DELETE_CASCADE?
<ajay.sonawane_at_gmail.com> a écrit dans le message de
news:1118899909.178803.13580_at_g44g2000cwa.googlegroups.com...
| Hello Experts
| I am new in Sql triggers and i would like some help
| I have a Table called ITEM and another callded SOURCE
| [ITEM]
| ItemNo,ItemName,SourceNo
|
| [Source]
| SourceNo,Source
|
| i want to create a Trigger so when i delete a record from [SOURCE] all
| the records in [ITEM] where item.SourceNo = [SourceNo that I deleted
| from SOURCE] will be deleted.
|
| How can i do that?
|
| Regards,
| Ajay Sonawane
| (Webtech Developers Pvt. Ltd. Pune )
|
No trigger needed, just declare constraints:
alter table source add constraint source_pk primary key (sourceno); alter table item add constraint item_source_fk foreign key (sourceno) references source on delete cascade;
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/clauses3a.htm#998196
Regards
Michel Cadot
Received on Thu Jun 16 2005 - 00:58:34 CDT