begin
/**
*
* Casting template
* @author xuyw
* @email[email protected]* @date 2014-05-19
*/
/*Cursor data variable uid*/
Declare uid varchar (128);
DECLARE DOTEFAULT 0;
/*Query all users*/
DECLARE CUR CURSOR for Select xxx from XX;
DECLARE CONTINUE HANDLER for Not Found Set Done = 1;
Open Cur;
/* Start the loop*/
Repeat
/* Extract data in the cursor*/
FETCH CUR INTO UID;
If done = 0 THEN
Execute your business
End if;
Unil Done = 1
End Repeat;
/*Close the cursor*/
Close Cur;
End;