-- end_of_month.sql

SELECT credit_limit, balance
  FROM account
 WHERE account_number = 1660
/

DECLARE
  limit NUMBER;
  bal NUMBER;
  interest NUMBER;
BEGIN
  SELECT credit_limit, balance
    INTO limit, bal
    FROM account
   WHERE account_number = 1660;

  IF limit < bal * 2 THEN
    interest := .2;
  ELSE
    interest := .1;
  END IF;

  UPDATE account
     SET balance = balance * (1 + interest)
   WHERE account_number = 1660;
END;
/

SELECT credit_limit, balance
  FROM account
 WHERE account_number = 1660
/
