You are on page 1of 1

196170307143 3360702

Practical- 8.a
Write stored routines such as write a routine for counting all product types
and other such routines can be performed.
➢ Write a CURSOR for selecting student_id whose name give into procedure argument.

CREATE FUNCTION FindStdID ( name_in VARCHAR(50) )


RETURNS INT
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE stdID INT DEFAULT 0;
DECLARE c1 CURSOR FOR
select student_id from student_marks
where name=name_in;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN c1;
FETCH c1 INTO stdID;
CLOSE c1;
RETURN stdID;
END;

➢ Write a CURSOR for selecting all student_id, name whose marks is more than 50.

You might also like