-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPL_SQL Trigger.txt
25 lines (24 loc) · 1.04 KB
/
PL_SQL Trigger.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
create database lib;
use lib;
create table library(bno int(5),bname varchar(40),author varchar(20),allowed_days int(5));
create table library_audit(bno int(5),old_all_days int(5),new_all_days int(5));
insert into library values(1,'Database Systems','Yash Marane',10);
insert into library values(2,'System Programming','Abhishek',20);
insert into library values(3,'Computer Network & Internet','Kapil',18);
insert into library values(4,'Project Management','Hariom',24);
insert into library values(5,'Python for Data Analysis','Tanmay',12);
select * from library;
delimiter //
create trigger tr1
before update on library
for each row
begin
insert into library_audit values(new.bno,old.allowed_days,new.allowed_days);
end //
update library set allowed_days=15 where bno=1; //
update library set allowed_days=25 where bno=2; //
update library set allowed_days=13 where bno=3; //
update library set allowed_days=19 where bno=4; //
update library set allowed_days=17 where bno=5; //
select * from library; //
select * from library_audit; //