DBMS Assignment6 Code
DBMS Assignment6 Code
ROLL NO : – 552
DBMSL T – 18
Assignment No - 6
Problem Statement :
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.
Stud_Marks(name, total_marks)
mysql> DELIMITER $
mysql> create procedure proc_grade(in rollno tinyint,in name varchar(15),in marks int)
-> begin
-> declare class varchar(25);
-> if marks>=990 and marks<=1500 then set class="Distinction";
-> elseif marks<=989 and marks>=900 then set class="First Class";
-> elseif marks<=899 and marks>=825 then set class="Second Class";
-> elseif marks<=824 and marks>=700 then set class="Pass";
-> else
-> set class="Fail";
-> end if;
-> insert into studmarks values(name,marks);
-> insert into result values(rollno,name,class);
-> end$
Query OK, 0 rows affected (0.08 sec)
mysql> DELIMITER $
mysql> call proc_grade(1,"Aryan",850);
-> DELIMITER $
Query OK, 1 row affected (0.34 sec)
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1
mysql> DELIMITER $
mysql> create function tot_stud(classname varchar(25))
-> returns int
-> begin
-> declare total int(20);
-> select distinct count(*) into total from result where class=classname;
-> return total;
-> end $
Query OK, 0 rows affected, 1 warning (0.07 sec)