0% found this document useful (0 votes)
21 views2 pages

Dbms 5 Stored Procedure and Function

The document contains two PL/SQL functions - one to check if an account is active and insert it into a new table if so, and another stored procedure to update a student's class grade based on their total marks using a grading system.

Uploaded by

wacih58121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Dbms 5 Stored Procedure and Function

The document contains two PL/SQL functions - one to check if an account is active and insert it into a new table if so, and another stored procedure to update a student's class grade based on their total marks using a grading system.

Uploaded by

wacih58121
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

2Q> function for active account and store in new table

acc_dets(account_no,branch_name,status)
acc_stats(account_no,branch_name)

Function:
create or replace function acc_33(macc_no in number,mbranch_name in varchar)
return number
is
mstatus varchar(15);
begin
select status into mstatus from acc_dets33 where acc_no=macc_no and branch_name =
mbranch_name;
if mstatus='active' then
insert into acc_sta33 values(macc_no,mbranch_name);
return 1;
else
return 0;
end if;
end;

Function Calling:
declare
macc_no number;
mbranch_name varchar(15);
ch number;
begin
macc_no := &acc_no;
mbranch_name := '&branch_name';
ch := acc_33(macc_no,mbranch_name);
if ch=1 then
dbms_output.put_line('THE ACCOUNT IS ACTIVE');
else
dbms_output.put_line('THE ACCOUNT IS INACTIVE');
end if;
end;
/

-----------------------------------------------------------------------------------
--------------------------------------------------

Q3>stored procedure for proc_grade use grading system


stud_marks(roll_no,name,total_marks)
result(roll_no,name,cl)

Procedure:
Create or Replace Procedure proc_grade(mmarks in
number, mroll in number) is
Begin
if mmarks>=90 and mmarks <=100 then
update result_33 set class= 'A' where roll_no=mroll;
elsif mmarks>=60 and mmarks<=89 then
update result_33 set class='B' where roll_no=mroll;
elsif mmarks>=50 and mmarks<60 then
update result_33 set class='C' where roll_no=mroll;
else
update result_33 set class='D' where roll_no=mroll;
end if;
End;
/
Procedure Calling:
Declare
mmarks number(4);
mroll number(4);
Begin
mroll:=&roll;
select roll_no,total_marks into mroll,mmarks from stud_marks33
where roll_no=mroll ;
proc_grade(mmarks, mroll );
End;
/

You might also like