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

Practical No 05

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)
22 views3 pages

Practical No 05

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

Practical No.

05
Name : Renuka Jadhav Roll No. : 49
Div : C

Aim : 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
marks899and 825 category is Higher Second Class. Write a PL/SQLblock to use procedure
created with above requirement. Stud_Marks(name, total_marks) Result(Roll,Name, Class)

mysql> show databases;


+--------------------+
| Database |
+--------------------+
| college |

| information_schema |
| library |
| mysql |
| performance_schema |
| practicle3 |

| renuka |
| sbibank |
| sys |
| user_auth |
+--------------------+

10 rows in set (0.01 sec)

mysql> use renuka;


Database changed
mysql> DELIMITER //
mysql> CREATE PROCEDURE set_class

-> (IN roll_no INT, IN name VARCHAR(30), IN total_marks INT)


-> BEGIN
-> IF total_marks <= 1500 AND total_marks >= 990 THEN
-> INSERT INTO result(roll_no, name, class)
-> VALUES(roll_no, name, 'Distinction');

-> ELSEIF total_marks < 990 AND total_marks >= 900 THEN
-> INSERT INTO result(roll_no, name, class)
-> VALUES(roll_no, name, 'First class');
-> ELSEIF total_marks < 900 AND total_marks >= 825 THEN
-> INSERT INTO result(roll_no, name, class)

-> VALUES(roll_no, name, 'Higher Second class');


-> END IF;
-> END //
Query OK, 0 rows affected (0.02 sec)

mysql> DELIMITER ;
mysql> CALL set_class(1,"renuka",1200);
Query OK, 1 row affected (0.01 sec)

mysql> select * from result;

+---------+--------+-------------+
| roll_no | name | class |
+---------+--------+-------------+
| 1 | renuka | Distinction |
+---------+--------+-------------+
1 row in set (0.00 sec)

mysql> call set_class(2,"jayjit",970);


Query OK, 1 row affected (0.01 sec)

mysql> select * from result;


+---------+--------+-------------+

| roll_no | name | class |


+---------+--------+-------------+
| 1 | renuka | Distinction |
| 2 | jayjit | First class |
+---------+--------+-------------+

2 rows in set (0.00 sec)

mysql> call set_class(3,"vishu",845);


Query OK, 1 row affected (0.01 sec)

mysql> select * from result;


+---------+--------+---------------------+
| roll_no | name | class |
+---------+--------+---------------------+
| 1 | renuka | Distinction |

| 2 | jayjit | First class |


| 3 | vishu | Higher Second class |
+---------+--------+---------------------+
3 rows in set (0.00 sec)

You might also like