16. Stored Procedures and Parameters
CREATE PROCEDURE • BEGIN • EXEC/CALL • ALTER PROCEDURE • DROP PROCEDURE
Up until this point, all of our data retrieval has been accomplished with a single SQL statement. Even the set logic seen in the previous chapter involved combining multiple SELECTs into a single statement. Now we’ll discuss a new scenario, in which multiple statements can be saved into a single object known as a stored procedure.
In broad terms, there are two general reasons for using stored procedures:
• To save multiple SQL statements in a single procedure
• To use parameters in conjunction with SQL statements
Stored procedures can, in fact, consist of a single SQL statement and contain no parameters. But ...