Database Reference
In-Depth Information
You might not have the security access needed to create stored proce-
dures. Many database administrators restrict stored procedure creation
rights, allowing users to execute them but not necessarily create them.
Nonetheless, stored procedures are useful and should be used whenever
possible.
Note
Can't Write Them? You Can Still Use Them MariaDB distinguishes the security and
access needed to write stored procedures from the security and access needed to
execute them. This is a good thing; even if you can't (or don't want to) write your own
stored procedures, you can still execute them when appropriate.
Using Stored Procedures
Using stored procedures requires knowing how to execute (run) them. Stored
procedures are executed far more often than they are written, so we start there.
And then we look at creating and working with stored procedures.
Executing Stored Procedures
MariaDB refers to stored procedure execution as calling , and so the MariaDB
statement to execute a stored procedure is simply CALL . CALL takes the name
of the stored procedure and any parameters that need to be passed to it. Take a
look at this example:
Input
CALL productpricing(@pricelow,
@pricehigh,
@priceaverage);
Analysis
Here a stored procedure named productpricing is executed; it calculates
and returns the lowest, highest, and average product prices. Of course, you
can't run this example yet, as stored procedure productpricing does not
exist. (Well, you could try to run it, but you'll just see a MariaDB error
message.)
Stored procedures might or might not display results, as you see shortly.
 
 
 
Search WWH ::




Custom Search