October 2022
Intermediate to advanced
380 pages
9h 35m
English
Stored procedures are a feature of SQL that developers can use to put custom code into the database itself, and call those procedures from their client application.
The following example shows a MySQL stored procedure that closes any outstanding bugs for a specified product. This is implemented in a procedure so that we can run this as an update, but in a prescribed way: only bugs that currently have a status of NEW or OPEN are closed by this action. If the application had direct access to update the bugs table, they might change the status of the wrong bugs.
| | CREATE PROCEDURE CloseUnresolvedBugsForProduct( |
| | IN given_product_id BIGINT UNSIGNED) |
| | BEGIN |
| | START ... |
Read now
Unlock full access