Example of Cursor in Mysql

DELIMITER //
 CREATE PROCEDURE myone()
  BEGIN
                declare myno  int(3);
     DECLARE done INT DEFAULT FALSE;
                declare mycursor CURSOR for  select roll_no from fine;
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
         open mycursor;
      Label1 : LOOP
                                fetch mycursor into  myno;
                              if done=TRUE then
                                    leave Label1;
                              end if;
                             select myno;
    END LOOP;
    close mycursor;
 END //


Popular posts from this blog

DDL DML DCL and TCL

Implementation of Calculator using lex and yacc

A Register Allocation algorithm that translates the given code into one with a fixed number of registers.