Subject | A trigger before delete.... |
---|---|
Author | akestion |
Post date | 2004-03-25T13:41:56Z |
Hi evryone,
I was wondering if i use a trigger before delete a master (in a
master details relation).
In order to delete all details before deleting the master.
exemple :
create table master
(
masterID smallint PRIMARY KEY ,
masterName varchar(30)
);
create table details
(
detailsID smallint PRIMARY KEY ,
detailsName varchar(30),
masterID smallint FOREIGN KEY
);
...
/*delete Operation in a SP : */
delete from master where masterID = :IDmaster;
...
A trigger fire before delete, for deleting details.
Does if the operation failed, the details be deleted and not the
master ?
And so we must use a transaction to enable Rollback !!
Or Does it make the rollback itself, if the operation which fire the
trigger failed ?
Thanks,
Akim
I was wondering if i use a trigger before delete a master (in a
master details relation).
In order to delete all details before deleting the master.
exemple :
create table master
(
masterID smallint PRIMARY KEY ,
masterName varchar(30)
);
create table details
(
detailsID smallint PRIMARY KEY ,
detailsName varchar(30),
masterID smallint FOREIGN KEY
);
...
/*delete Operation in a SP : */
delete from master where masterID = :IDmaster;
...
A trigger fire before delete, for deleting details.
Does if the operation failed, the details be deleted and not the
master ?
And so we must use a transaction to enable Rollback !!
Or Does it make the rollback itself, if the operation which fire the
trigger failed ?
Thanks,
Akim