Get the App
SLTechnology News&Howtos  ›  Database  › 

How to define parameters in MySql stored procedures

Shulou Source: shulou.com Published: 2022-05-31 11:35:26 09月21日 Update

Editor to share with you how to define parameters in MySql stored procedures. I hope you will gain something after reading this article. Let's discuss it together.

1. Parameter classification

Parameters, like stored procedures in MySql, can also take parameters. We do not use parameters in the previous example, but we will use parameters in the following example. Parameters of MySql are divided into three categories: IN, OUT, and INOUT, even literally these three types of parameters are easy to understand:

IN: this is the default type, that is, if the parameter does not specify a type, then the default is the IN type. This parameter is mainly the passed value, which is provided to the stored procedure. In addition, the changes made by the stored procedure will not affect the passed parameters.

OUT: this is mainly the value that the stored procedure passes out, that is, the stored procedure changes it to you and passes it back to the program that called it.

NOUT: the above two features are combined, that is, the value can be passed to the stored procedure, and the stored procedure can also change the value in passing to the program that calls it.

2. Parameter definition

The parameters are defined as follows:

MODE param_name param_type (param_size)

Where MODE can be IN, OUT, INOUT;param_name is the parameter name, and param_type is the type. Of course, it is important to note that the name cannot be the same as the field in the table.

After reading this article, I believe you have some understanding of "how to define parameters in MySql stored procedures". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Parameters procedures storage types that is examples that is programs articles two functions at the same time names fields literally done more features knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Docker macOS Redmi MariaDB