MySQL Branch and loop structure

Source: Internet
Author: User

1. If Else branch

1 Create procedurePD_TESTIF2 (inchNumint, outStr varchar)2     begin 3         ifNum=1  Then4         Set Str='a';5ElseIf num=2  Then6         Set Str='two';7         End if;8     End;9 --calledTenCall PD_TESTIF2 (1,@str); One Select @str;

Execution Result: a

2. Circulation

1 Create procedurePd_testwhile22 (inchNumint, outsum int)2     begin3         --Defining Variables4         DeclareIint default 1;5         Declare sum int default 0;6        --Cycle Conditions7          whileI<Num do8         SetVsum=Vsum+i;9         SetI=I+1;Ten         --End Loop One         End  while; A         Set sum=vsum; - End; -Call Pd_testwhile22 ( -,@str); the Select @str;

Execution Result: 5050

MySQL Branch and loop structure

Related Article

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.