Term Fly Presents http://www.flyheart.com
program run from a session with EXECUTE authority on the package. This is always a bad idea and should be avoided.
FUNCTION days_overdue (isbn_in IN book.isbn%TYPE) RETURN INTEGER;
-- Relies on g_daily_fine for calculation FUNCTION fine (isbn_in IN book.isbn%TYPE) RETURN INTEGER;
The following rewrite of overdue_ pkg fixes the problem; for the sake of the trees, I show only the replacement of the g_daily_fine variable with its "get and set" programs:
CREATE OR REPLACE PACKAGE overdue_pkg
PROCEDURE set_daily_fine (fine_in IN NUMBER); PROCEDURE daily_fine RETURN NUMBER;
Now it's impossible to bypass the business rule for the daily fine.
By hiding the data structure, you give yourself the freedom to change how that data is defined without affecting all accesses to the data.
Package data can now be accessed from Oracle Developer tools, such as
Formsbuilder. You may not, from "client-side" PL/SQL (i.e., code written in Oracle Developer components) reference stored package elements unless they are procedures or functions.