0% found this document useful (0 votes)
5 views3 pages

DBMS - 6

Uploaded by

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

DBMS - 6

Uploaded by

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

NAME: RIYA RAJESH AVASTHI

BATCH : T1
ROLL NO.: 3

Assignment No. 06

Title: PL/SQL Stored Procedure and Stored Function. Write a Stored


Procedure namely proc_ Grade for the categorization of student. if
marks scored by students in examination is <=1500 and marks>=990
then student will be placed in distinction category if marks scored are
between 989 and900 category is first class, if marks 899 and 825
category is Higher Second Class Write a PL/SQL block for using
procedure created with above requirement.

PROGRAM-

create table Stud_Marks(


NAME varchar2(20),ROLL_NO number(5),
TOTAL_MARKS number(5)
);
INSERT INTO Stud_Marks VALUES('RAJ' ,1, 1499);
INSERT INTO Stud_Marks VALUES('RIYA' ,2, 999);
INSERT INTO Stud_Marks VALUES('PRIYA' ,3, 870);
INSERT INTO Stud_Marks VALUES('SNEHA',4, 942);
INSERT INTO Stud_Marks VALUES('PURVA' ,5, 889);
INSERT INTO Stud_Marks VALUES('PURVA' ,6, 700);

create table Result(


ROLL_NO number(5),
CLASS varchar2(20)
);

create or replace PROCEDURE PROC_GRADE AS


BEGIN
FOR i IN (SELECT * FROM Stud_Marks)
LOOP
DBMS_OUTPUT.PUT_LINE('Student Name: ' || i.Name || ' Student Marks: ' ||
i.Total_Marks);
IF i.Total_Marks <=1500 AND i.Total_Marks >=990 THEN INSERT INTO Result
VALUES (i.ROLL_NO,'Distinction'); ELSIF i.Total_Marks <=989 AND i.Total_Marks
>=900 THEN INSERT INTO Result VALUES (i.ROLL_NO,'First Class'); ELSIF
i.Total_Marks <=899 AND i.Total_Marks >=825 THEN INSERT INTO Result
VALUES (i.ROLL_NO,'Higher Second Class');
ELSE
INSERT INTO Result VALUES (i.ROLL_NO,'Fail'); END IF;
END LOOP;
--COMMIT;
END;
/
execute PROC_GRADE;
select * from Result;

OUTPUT
SQL> @assi6
Table created.

1 row created.

1 row created.

1 row created.

1 row created.

1 row created.

1 row created.

Table created.

Procedure created.

Student Name: RAJ Student Marks: 1499 Student


Name: RIYA Student Marks: 999 Student Name:
PRIYA Student Marks: 870 Student Name: SNEHA
Student Marks: 942 Student Name: PURVA
Student Marks: 889 Student Name: PURVA
Student Marks: 700

PL/SQL procedure successfully completed.

ROLL_NO CLASS
---------- -------------------- 1 Distinction
2 Distinction
3 Higher Second Class
4 First Class
5 Higher Second Class
6 Fail

6 rows selected.

You might also like