Use of variables, use of cursors, use of process controls

Source: Internet
Author: User

Special attention to the location of the symbol and there is NO!!!

First create the table T_user:

Delimiter as the start and end of execution:

Create a stored procedure Pro_user (), define a variable:

Then create a stored procedure and assign a value to the variable:

Call stored Procedure Pro_user2 ():

Next, create the table t_user2 and insert a data from the table into the table T_user:

First create the table T_user2:

Then create the stored procedure Pro_user3 () and insert the T_USER2 data into the T_user:

Call the T_user before the stored function Pro_user3 ():

Then: Call Pro_user3 ();

T_user after calling Pro_user3 (): Inserts the data id2=1 in T_user2.

Next is the use of cursors:

Insert T_user2 data into table T_user with a cursor:

First create a stored procedure and make a cursor declaration, open, use, close:

T_user before calling the stored function pro_user4 ():

After the call:

Next, the use of Process control:

Create a stored procedure 5 and operate on T_user:

If you can find the data to update, otherwise insert a piece of data into the table T_user:

T_user Raw DATA:

To execute the call store function:

For table T_user Operations, use case:

T_user before calling the stored function:

After the call:

LOOP, leave statement:

Calling a stored function: Inserting data continuously into a table

Next:

Itearate statement: equivalent to continue.

The result can be seen that id=3 is skipped and not shown:

Next Repeat statement:
Special attention to symbol position and there is no!!!

Stop inserting data to 5!

Next while statement:

Use of variables, use of cursors, use of process controls

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.