Parameters of the stored procedure

Source: Internet
Author: User

Stored procedure arguments: in parentheses in the stored procedure, you can declare parameters. The syntax is:CREATE PROCEDURE P ([in/out/inout] parameter Name argument type ...) , the MySQL stored procedure parameter will default to in if not explicitly specified in, out, InOut

In: parameters for incoming function

Create procedureP7 (inchNint)begin    DeclareNumint default 0; DeclareTotalint default 0;  whileNum<=N doSetTotal:=Total+num; SetNum:=Num+ 1; End  while; SelectTotal ;End$

Invoke: Call-------->5050 (1+2+3+....+100)/call (+)--------------->55 (1+2+3+.........+10)

Out: An external variable that can be understood as a function to be changed, regardless of what value the variable is outside, the initial value inside is null, and the internal effect on it will change the value of the external variable, that is, the value of the function calculation is mapped to the outside of the function

Create procedureP8 (inchNint, out Totalint)begin    DeclareNumint default 0; SetTotal:= 0;  whileNum<=N doSetTotal:=Total+num; SetNum:=Num+ 1; End  while;End$

Invoke: Call P8 (10,@C); Select @c;-----------------> Printing 55

InOut: declares global for a function internally and may modify the value of the variable

Create procedure int begin    set Age:=+; End$

Call: Set @age: = 20;    Call P9 (@age);     Select @age; Printing 40

Parameters of the stored procedure

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.