Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on trigger

Status
Not open for further replies.

Leon1977

IS-IT--Management
Jun 27, 2001
79
BG
I want to make a trigger before delete
I have departments and PERSONS with foreign key to departments
so before deleteing a row in departments I want to Upadte the the foreign key in PERSONS to point somewhere else..

create or replace trigger Department_Triger
BEFORE delete on departments
for each row
declare
-- local variables here
begin
Update PERSONS
SET FK_DEPARTMENT_ID=0
where FK_DEPARTMENT_id=???old.DEPARTMENT_ID;???
end Department_Triger;
but there is an error with old.DEPARTMENT_ID;
How shoul I tell the triger the ID of the deleted row
 
To reference an old value you may use :eek:ld.DEPARTMENT_ID.
Though, with foreign key you should solve mutating trigger problem also (there were a lot of threads on this issue, don't start a new one please).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top