Home  >  Article  >  Database  >  What are the different modes of parameters used by MySQL stored procedures?

What are the different modes of parameters used by MySQL stored procedures?

WBOY
WBOYforward
2023-09-06 18:09:131255browse

What are the different modes of parameters used by MySQL stored procedures?

#Parameters make stored procedures more useful and flexible. In MySQL we have following three modes -

IN mode

It is the default mode. When we define IN parameters in a stored procedure, the calling program must pass the parameters to the stored procedure. The value of the IN parameter is protected, which means that even if the value of the IN parameter changes within the stored procedure; its original value is retained after the stored procedure ends.

OUT Pattern

>OUT parameters can be changed inside a stored procedure and have their new values ​​passed back to the calling program. It should be noted that the initial value of the OUT parameter cannot be accessed when the stored procedure is started.

INOUT mode

INOUT parameter is a combination of IN and OUT parameters, which means The calling program can pass parameters, and the stored procedure can modify the INOUT parameters and pass the new values ​​back to the calling program.

Syntax for defining parameters

The following is the syntax for defining parameters in a stored procedure-

MODE parameter_name parameter_type(parameter_size)

Here, MODE can be IN, OUT or INOUT, depending on the storage The purpose of the parameters in the purpose.

  • Parameter_name is the name of the parameter.
  • Parameter_type is the data type of the parameter.
  • Parameter_size is the size of the parameter

The above is the detailed content of What are the different modes of parameters used by MySQL stored procedures?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete