5.4.2 The inventory_held_by_customer Function

The inventory_held_by_customer function returns the customer_id of the customer who has rented out the specified inventory item.

Parameters
  • p_inventory_id: The ID of the inventory item to be checked.

Return Values

This function returns the customer_id of the customer who is currently renting the item, or NULL if the item is in stock.

Sample Usage
mysql> SELECT inventory_held_by_customer(8);
+-------------------------------+
| inventory_held_by_customer(8) |
+-------------------------------+
|                          NULL |
+-------------------------------+
1 row in set (0.00 sec)

mysql> SELECT inventory_held_by_customer(9);
+-------------------------------+
| inventory_held_by_customer(9) |
+-------------------------------+
|                           366 |
+-------------------------------+
1 row in set (0.00 sec)