Rechercher dans le manuel MySQL
13.6.4 Variables in Stored Programs
System variables and user-defined variables can be used in stored
programs, just as they can be used outside stored-program context.
In addition, stored programs can use DECLARE
to
define local variables, and stored routines (procedures and
functions) can be declared to take parameters that communicate
values between the routine and its caller.
To declare local variables, use the
DECLARE
statement, as described in Section 13.6.4.1, “Local Variable DECLARE Syntax”.Variables can be set directly with the
SET
statement. See Section 13.7.5.1, “SET Syntax for Variable Assignment”.Results from queries can be retrieved into local variables using
SELECT ... INTO
or by opening a cursor and usingvar_list
FETCH ... INTO
. See Section 13.2.10.1, “SELECT ... INTO Syntax”, and Section 13.6.6, “Cursors”.var_list
For information about the scope of local variables and how MySQL resolves ambiguous names, see Section 13.6.4.2, “Local Variable Scope and Resolution”.
It is not permitted to assign the value DEFAULT
to stored procedure or function parameters or stored program local
variables (for example with a SET
statement). In MySQL 8.0, this results in a syntax
error.
var_name
= DEFAULT
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-stored-program-variables.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.