5.3.1 The film_in_stock Stored Procedure

Description

The film_in_stock stored procedure determines whether any copies of a given film are in stock at a given store.

Parameters
  • p_film_id: The ID of the film to be checked, from the film_id column of the film table.

  • p_store_id: The ID of the store to check for, from the store_id column of the store table.

  • p_film_count: An OUT parameter that returns a count of the copies of the film in stock.

Return Values

This procedure produces a table of inventory ID numbers for the copies of the film in stock, and returns (in the p_film_count parameter) a count that indicates the number of rows in that table.

Sample Usage
mysql> CALL film_in_stock(1,1,@count);
+--------------+
| inventory_id |
+--------------+
|            1 |
|            2 |
|            3 |
|            4 |
+--------------+
4 rows in set (0.01 sec)

Query OK, 1 row affected (0.01 sec)

mysql> SELECT @count;
+--------+
| @count |
+--------+
|      4 |
+--------+
1 row in set (0.00 sec)