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
define local variables, and stored routines (procedures and
functions) can be declared to take parameters that communicate
values between the routine and its caller.
Results from queries can be retrieved into local variables
INTO or by
opening a cursor and using
FETCH ... INTO
Section 184.108.40.206, “
SELECT ... INTO
Syntax”, and Section 13.6.6, “Cursors”.
For information about the scope of local variables and how MySQL resolves ambiguous names, see Section 220.127.116.11, “Local Variable Scope and Resolution”.
Copyright © 1997, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices