Create or replace trigger t1 after insert on deposit for each row begin if :new.damt>0 then update cust set cbal=cbal+:new.damt where :new.ano=cust.ano; update bank set asset=asset+:new.damt where :new.brid=bank.brid; end if; end;
insert into deposit values('1-06-2014',12000,'0004','3');
ANO CNAME CBAL 0004 Priya 15000 0006 Rani 7000 0005 Raja 5000
select * from bank;
BRID ASSET 3 312000 1 100000 2 200000
Create or replace trigger t2 after insert on loan for each row begin if :new.lamt>0 then update cust set cbal=cbal+:new.lamt where :new.ano=cust.ano; update bank set asset=asset-:new.lamt where :new.brid=bank.brid; dbms_output.put_line('customer and bank account updated'); end if; end;
insert into loan values('L3','10000','0004','3')
select * from bank BRID ASSET 3 302000 1 100000 2 200000
select * from cust
ANO CNAME CBAL 0004 Priya 25000 0006 Rani 7000 0005 Raja 5000
create or replace assertion check (select sum(lamt) from loan)>(select sum(asset) from bank)
insert into sa09 values('BE-ME' , 120 , 0) insert into sa09 values('BE-EEE ', 60 , 1) insert into sa09 values('BE-CIVIL ', 60 , 1)
insert into vp09 values('BE-CIVIL ','59') insert into vp09 values('BE-EEE ','59') insert into vp09 values('BE-ME',120) select * from vp09
DEPT VP BE-CIVIL 59 BE-ME 120 BE-EEE 59
Create or replace trigger t3 after insert on ad09 for each row begin if :new.sreg>0 then update sa09 set dsa=dsa+1 where :new.dept=sa09.dept; update vp09 set vp=vp-1 where :new.dept=vp09.dept; end if; dbms_output.put_line('Seat Allocation and Vacancy position updated'); end;
insert into ad09 values('1235','BE-ME','07-29-2013')