0% found this document useful (0 votes)
11 views

group (A) 5

Uploaded by

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

group (A) 5

Uploaded by

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

OUTPUT:

mysql> create table result(roll_no int,name varchar(20),class varchar(20));


Query OK, 0 rows affected (0.02 sec)

mysql> insert into marks values('1','Samarth','1400');


Query OK, 1 row affected (0.01 sec)

mysql> insert into marks values('2','Suraj','980');


Query OK, 1 row affected (0.01 sec)

mysql> insert into marks values('3','Sam','880');


Query OK, 1 row affected (0.01 sec)

mysql> insert into marks values('4','Siddhi','820');


Query OK, 1 row affected (0.01 sec)

mysql> insert into marks values('5','Ani','740');


Query OK, 1 row affected (0.01 sec)

mysql> insert into marks values('6','patil','640');


Query OK, 1 row affected (0.01 sec)

mysql> delimiter //
mysql> create procedure proc_result(in marks int,out class
-> char(20))
-> begin
-> if(marks<1500&&marks>990)
-> then
-> set class='Distincton';
-> end if;
-> if(marks<989&&marks>890)
-> then
-> set class='First Class';
-> end if;
-> if(marks<889&&marks>825)
-> then
-> set class='Higher Second Class';
-> end if;
-> if(marks<824&&marks>750)
-> then
-> set class='Second Class';
-> end if;
-> if(marks<749&&marks>650)
-> then
-> set class='Passed';
-> end if;
-> if(marks<649)
-> then
-> set class='Fail';
-> end if;
-> end;
-> //
Query OK, 0 rows affected, 5 warnings (0.01 sec)
mysql> create function final_result4(R1 int)
-> returns int
-> READS SQL DATA
-> DETERMINISTIC
-> begin
-> declare fmarks integer;
-> declare grade varchar(20);
-> declare stud_name varchar(20);
-> select marks.total_marks,marks.name into
-> fmarks,stud_name from marks where marks.roll_no=R1;
-> call proc_result(fmarks,@grade);
-> insert into result values(R1,stud_name,@grade);
-> return R1;
-> end;
-> //
Query OK, 0 rows affected (0.01 sec)

mysql> select final_result4(2);


-> //
+------------------+
| final_result4(2) |
+------------------+
| 2|
+------------------+
1 row in set (0.01 sec)

mysql> select final_result4(3);//


+------------------+
| final_result4(3) |
+------------------+
| 3|
+------------------+
1 row in set (0.01 sec)

mysql> select final_result4(4);//


+------------------+
| final_result4(4) |
+------------------+
| 4|
+------------------+
1 row in set (0.01 sec)

mysql> select final_result4(5);//


+------------------+
| final_result4(5) |
+------------------+
| 5|
+------------------+
1 row in set (0.00 sec)
mysql> select * from result;
-> //
+---------+--------+---------------------+
| roll_no | name | class |
+---------+--------+---------------------+
| 2 | Suraj | First Class |
| 3 | Sam | Higher Second Class |
| 4 | Siddhi | Second Class |
| 5 | Ani | Passed |
+---------+--------+---------------------+
4 rows in set (0.00 sec)

You might also like