DBMS Practical 4
DBMS Practical 4
PROBLEM STATEMENT:
Consider Tables:
1. Borrower(Roll_no, Name, Date of Issue, Name of Book, Status)
2. Fine(Roll_no, Date, Amt)
• Accept Roll_no and Name of Book from user.
• Check the number of days (from date of issue).
• If days are between 15 to 30 then fine amount will be Rs 5per day.
• If no. of days>30, per day fine will be Rs 50 per day and for days less than 30, Rs. 5
per day
CODE:
Delimiter //
create procedure efine(IN rollno1 int, IN bname1 varchar(20))
begin
declare fine float;
declare days int;
declare idate date;
select dateofissue into idate from borrower where rollno=rollno1 and bname =
bname1;
select datediff(curdate(),idate) into days;
if days>15 and days<=30 then
set fine=(days-15)*5;
insert into fine values(rollno1,bname1,fine);
elseif days>30 then
set fine = (days-30)*50 + 15*5;
insert into fine values(rollno1,bname1,fine);
end if;
update borrower set status = ‘r’ where rollno=rollno1 and bname=bname1;
end //
delimiter ;
call afine(1,’maths’);
call afine(2,’english’);
call afine(3,’marathi’);
OUTPUT: