Database Reference
In-Depth Information
stored procedure code itself is enclosed within BEGIN and END statements as
seen before, and a series of SELECT statements are performed to retrieve the
values that are then saved into the appropriate variables (by specifying the INTO
keyword).
Note
Parameter Datatypes The datatypes allowed in stored procedure parameters are the
same as those used in tables. Appendix C, “MariaDB Datatypes,” lists these types.
Note that a recordset is not an allowed type, and so multiple rows and columns could
not be returned via a parameter. This is why three parameters (and three SELECT
statements) are used in the previous example.
To call this updated stored procedure, three variable names must be specified,
as seen here:
Input
CALL productpricing(@pricelow,
@pricehigh,
@priceaverage);
Analysis
As the stored procedure expects three parameters, exactly three parameters must
be passed, no more and no less. Therefore, three parameters are passed to this
CALL statement. These are the names of the three variables that the stored pro-
cedure will store the results in.
Note
Variable Names All MariaDB variable names must begin with @ .
When called, this statement does not actually display any data. Rather, it
returns variables that can then be displayed (or used in other processing).
To display the retrieved average product price you could do the following:
Input
SELECT @priceaverage;
Output
+---------------+
| @priceaverage |
+---------------+
| 16.133571428 |
+---------------+
Search WWH ::




Custom Search