Pl/sql

 create procedure fine_calculation(IN rno int(3), bname varchar(20))

 begin

 declare i_date date;

 declare diff int;

 declare fine_amt int;

 declare exit handler for sqlexception select'table not found';

 select dateofIssue into i_date from borrower where rollin=rno and bname = bname;

 select datediff(curedate(),i_date) into diff;

 if(diff>15 and diff<=30) then

 set fine_amt = diff*5;

 insert into fine values (rno,curdate(),fine_amt);

 elseif(diff>30)then

 set fine_amt = 15*5 + (diff-30)*50;

 insert into fine values (rno,curdate(),fine_amt);

 end if;

 update borrower set statu = 'r' where rollin=rno and bname = bname;

 end;

 $

Comments

Popular posts from this blog

DREAM LEAGUE SOCCER 2019 MOD

10 CL3

Garena Contra Return