Objective
Create a hostel accounting system
Program
SQL>create table hostel(stud_id varchar(10) primary key,
stud_name varchar(20), rent number(6,2), mess number(6,2),ectr number(6,2),
days number(2) check(days<31)and (days>0));
Table created
SQL>insert into hostel values(‘100’,’vishnu’,12,5,3,24);
1 row created
SQL>insert into hostel values(‘101’,’rabeeh’,12,5,3,20);
1 row created
SQL>insert into hostel values(‘102’,’tinu’,12,5,3,28);
1 row created
SQL>insert into hostel values(‘103’,’sarath’,12,5,3,14);
1 row created
SQL> alter table hostel add(tot_fee number(6,2));
Table altered
SQL>ed hostel
Declare
Cursor h is select * from hostel;
V_t hostel.tot_fee%type;
Begin
For i in h loop
V_t:=(h.rent+h.mess+h.ectr)*h.days;
Update hostel set tot_fee=v_t where stud_id = h.stud_id;
End loop;
End;
SQL>@hostel
SQL> /
PL/SQL procedure successfully completed
SQL> select * from hostel;
STUD_ID
STUD_NAME RENT MESS
ECTR DAYS TOT_FEE
100
vishnu 12 5 3
24 480
101
rabeeh 12 5 3
20 400
102
tinu 12 5 3 28 560
103
sarath 12 5 3
14 280
0 comments:
Post a Comment