Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report