MySQL cursors Use

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.