Calling Stored Programs from Stored Programs
Calling one stored program from another is perfectly
simple. You do this with the CALL
statement, just as you would from the MySQL
command-line client.
Figure 2-15 shows a
simple stored procedure that chooses between two stored procedures
based on an input parameter. The output of the stored procedure
(l_bonus_amount is populated from
an OUT parameter) is passed to a
third procedure.
Here is an explanation of the significant lines:
Line(s) | Explanation |
|---|---|
11 | Determine if the employee is a
manager. If he is a manager, we call the |
12 and 14 | With both stored procedures, pass in
the |
16 | Call the |

Figure 2-15. Example of calling one stored procedure from another
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access