I am trying to create a trigger which will enter values into a table terminated_employees when we delete values from the nm_employees table. I have written the trigger but it I am getting compilation errors for the PL statement. Any ideas?
CREATE TABLE nm_departments(
dept2 varchar(20),
CONSTRAINT empPK PRIMARY KEY (dept2)
);
CREATE TABLE nm_employees(
name varchar(20),
dept varchar(20),
CONSTRAINT departments FOREIGN KEY (dept) REFERENCES nm_departments (dept2)ON DELETE CASCADE
);
CREATE TABLE terminated_employees(
te_name varchar(20),
te_dept varchar(20)
);
CREATE OR REPLACE TRIGGER DeleteCustomer
BEFORE DELETE ON nm_employees
FOR EACH ROW
BEGIN
INSERT INTO terminated_employees (te_name,te_dept)
VALUES(:Old.te_name, :Old.te_dept);
END DeleteCustomer;
This will compile, if you are writing trigger on *nm_employees* than this will be the code you have to write