A6
A6
RollNo:-T212019
Batch :-TEB(2).
Aim:
Write a PL/SQL block of code using parameterized Cursor, that will merge the
data available in the newly created table N_RollCall with the data available in the
table O_RollCall. If the data in the first table already exist in the second table
then that data should be skipped.
mysql> delimiter $$
mysql> create procedure set_cursor() begin declare rollno int; declare marks int;
declare flag int; declare c1 cursor for select roll_no, total_marks from
stud_marks; open c1; l1:loop fetch c1 into rollno, marks; set flag=0; select
roll_no into flag from new_stud_marks where new_stud_marks.roll_no = rollno; if
flag = 0 then if marks<=1500 and marks>=990 then insert into new_stud_marks
values(rollno,'DIST'); end if; if marks<990 and marks>=900 then insert into
new_stud_marks values(rollno,'FC'); end if; if marks<900 and marks>=825 then insert
into new_stud_marks values(rollno,'HSC'); end if; if marks<825 and marks>=750 then
insert into new_stud_marks values(rollno,'SC'); end if; if marks<750 and marks>=600
then insert into new_stud_marks values(rollno,'PC'); end if; if marks<600 then
insert into new_stud_marks values(rollno,'FAIL'); end if; end if; end loop l1;
close c1; end$$
Query OK, 0 rows affected (0.03 sec)