DBMS A 4
DBMS A 4
4
Aim: Unnamed PL/SQL code block: Use of Control structure and Exception handling is ma
ndatory. Suggested Problem statement: Consider Tables: 1. Borrower(Roll_no, Name, Dateof
Issue, NameofBook, Status) 2. Fine(Roll_no,Date,Amt) • Accept Roll_no and NameofBook f
rom user. • Check the number of days (from date of issue). • If days are between 15 to 30 the
n 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. • After submitting the book, status will change from I to
R. • If condition of fine is true, then details will be stored into fine table. • Also handles the e
xception by named exception handler or user define exception handler.
Code:
Borrow Table :
desc Borrower;
Fine Table:
rollno number(20);
name varchar(50);
amt int;
doi date;
System_date date;
no_of_days number(20);
begin
rollno:=:rollno;
name:=:name;
dbms_Output.put_line(doi);
no_of_days:=System_date - doi;
dbms_Output.put_line(no_of_days);
amt:=no_of_days*5;
dbms_Output.put_line('amount'||amt);
amt:=no_of_days*50;
dbms_Output.put_line('amount'||amt);
else
dbms_Output.put_line('No fine');
end if;
if no_of_days>15 then
end if;
exception
end;
Output:
04/12/2010
4539
amount226950