/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
DROP PROCEDURE IF EXISTS cur_movie; delimiter // CREATE PROCEDURE cur_movie() BEGIN DECLARE mname VARCHAR(100); DECLARE yr INT; DECLARE flag INT DEFAULT 0; DECLARE c cursor FOR SELECT movie_name,release_year FROM movie; DECLARE exit handler FOR NOT found SET flag=1; OPEN c; fetch c INTO mname, yr; loop SELECT mname AS MovieName ,yr AS ReleaseYear; fetch c INTO mname,yr; END loop; close c; END // delimiter ;
URL: http://www.gladsys.in/blog/stored-procedures-in-mysql/