MySQL Storage procedure 2: variable definition and parameter passing

Source: Internet
Author: User

variable definitions in the #储存过程DeclareVariable name type Optional type--It's like building a watch .Create procedurep ()begin    DeclareAgeint default( -); Declare  Number int default 1; SelectAge+ Number; End$/*mysql> CREATE Procedure P (), Begin, declare age int default (18);    -Declare number int default 1;    Select Age+number; End$query OK, 0 rows Affected (0.00 sec) mysql> Call p$+------------+|         Age+number |+------------+| |+------------+1 Row in Set (0.00 sec) Query OK, 0 rows affected (0.01 sec)*/in #储存过程, variables can be assigned to variables using the result of the # operation:SetAge:=Expression #SetAge:=Age+ 2



#参数传递mysql> Create procedureP2 ( Number int, ageint)     -       begin     -         SelectAge+ Number;  -       End$Query OK,0Rows Affected (0.00sec) MySQL>Call P2 (1,2)$+------------+|Age+ Number |+------------+|          3 |+------------+1Rowinch Set(0.00sec) Query OK,0Rows Affected (0.01sec) MySQL>

MySQL Storage procedure 2: variable definition and parameter passing

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.