Get the App
SLTechnology News&Howtos  ›  Database  › 

A case study of in, out and inout parameters of MySQL stored procedures

Shulou Source: shulou.com Published: 2022-05-31 23:59:24 09月21日 Update

Editor to share with you the MySQL stored procedure in, out, inout parameters of the case, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Article catalogue

Stored procedure

1. Create stored procedures and view global variables

two。 The change in the value of a global variable when calling a stored procedure

Stored procedure

1. Create stored procedures and view global variables

Mysql > create database yy;Query OK, 1 row affected (0.00 sec) mysql > use yy;Database changedmysql > set @ num1=10,@num2=20,@num3=30; / / set the global variable mysql > delimiter $$mysql > create procedure p (in num1 int,out num2 int,inout num3 int)-> begin-> select num1,num2,num3;-> set num1=100,num2=200,num3=300;-> select num1,num2,num3;-> end $$Query OK, 0 rows affected (0.00 sec) mysql > delimiter Mysql > call p (@ num1,@num2,@num3)

Summary 1:

The in and inout parameters pass the value of the global variable into the stored procedure, while the out parameter does not pass the value of the global variable into the stored procedure. In the use of stored procedures, the parameter values in, out, and inout all change.

two。 The change in the value of a global variable when calling a stored procedure

Mysql > select @ num1,@num2,@num3

Summary 2:

When the stored procedure is called, it is found that the in parameter will not change the value of the global variable, while the out and inout parameters will change the value of the global variable after calling the stored procedure and assign the referenced value of the stored procedure to the global variable.

The in parameter assignment type can be a variable and a fixed value, while the out and inout parameter assignment type must be a variable.

These are all the contents of this article entitled "the case of MySQL stored procedure in, out, inout parameters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Process storage global variable parameter change article case content type value not much most article more catalog knowledge industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Shulou Tech Info Xiaomi Redmi