Syntax for cursors
--defining cursor state variablesDECLARE DoneINT DEFAULT 0;--Defining CursorsDECLAREcursor_nameCURSOR for(SELECTselect_expr fromTable_references)--Set to 1 when the cursor cannot find the dataDECLARE CONTINUEHANDLER notfoundSETDone= 1;OPENcursor_name;--Open CursorFETCHCursor_name intoVariable_name;--The data of the cursor is taken out into the variable of the corresponding positionCLOSEcursor_name;--The cursor must be closed after use--the variable names 1.FETCH cursor_name into are required to be defined using declare, and the order must precede the cursor definition. --the number of data columns for the 2.CURSOR for query must be the same as the number of variables that fetch cursor_name into to, otherwise the data will not be taken, null. --3.FETCH cursor_name into to the variable name cannot be the same as the SELECT query column name, using the AS alias is not
Knowledge Expansion:
The reason why the 1.MySQL cursor value is empty-->https://www.cnblogs.com/sidesky/p/3432110.html
2.MySQL cursor Nesting-->https://www.cnblogs.com/phao123/p/6006780.html
Bug-->http://www.cnblogs.com/leohahah/p/9401343.html for 3.MySQL cursors to remove null values
The definition and usage of the 4.MySQL mid-stream standard-->50848216
MySQL cursors Use