create table branch_audit
(br_branchno varchar(4),
br_branchname varchar(20),
br_street varchar(40) not null unique,
br_city varchar(20),
br_state varchar(2),
br_zipcode varchar(5),
br_phone varchar(10),
br_fax varchar(10),
br_per_mgt_fee decimal(5,2),
br_email varchar(25),
constraint br_primarykey primary key (br_branchno));
The above line creates the audit table with the same schema as the "branch" table so that it can capture all the old data that has been deleted
This is the trigger statement, very basic form and I was wondering if there was a way of preserving its simplicity:
CREATE TRIGGER trigger_deleteon
AFTER DELETE
ON branch
FOR EACH ROW
INSERT INTO branch_audit VALUES(select * from branch);
DELETE FROM Branch WHERE CL_CLIENTNO = 'B001';
I'm going to try my best to explain here. So I would like the code to take the deleted value after the trigger has been activated and then take the tuple(row) that has been deleted and store it in an Audit table I have created in order to track modifications to the DB.
The underlined statement above is the statement that mus be changed to capture just the deleted tuple, currently it captures every tuple instead of just the one updated.