5.4.1 The get_customer_balance Function

The get_customer_balance function returns the current amount owing on a specified customer's account.

Parameters
  • p_customer_id: The ID of the customer to check, from the customer_id column of the customer table.

  • p_effective_date: The cutoff date for items that will be applied to the balance. Any rentals, payments, and so forth after this date are not counted.

Return Values

This function returns the amount owing on the customer's account.

Sample Usage
mysql> SELECT get_customer_balance(298,NOW());
+---------------------------------+
| get_customer_balance(298,NOW()) |
+---------------------------------+
|                           22.00 |
+---------------------------------+
1 row in set (0.00 sec)