Creating subprograms within a package is the next step in developing a packaged procedure. You must decide which routines will be application-interface routines and which routines will be available only within the package. This determines where the subprogram specification will reside—in the package or in the package body. There are two types of subprograms in PL/SQL, procedures and functions.
Procedure Definition
To define a procedure, you must specify a routine name and the parameters to be passed in and out of the routine. In the order_total example, the following code defines the application-interface routine and resides in the package specification area:
PROCEDURE
get_order_total (
in_order_num IN NUMBER,
out status_code OUT VARCHAR2,
out_msg OUT VARCHAR2,
out_merch_total OUT NUMBER,
out_shipping IN OUT NUMBER,
out_taxes IN OUT NUMBER,
out_grand_total OUT NUMBER
);
The PROCEDURE statement begins the definition of the package application-interface routine get_order_total. Enclosed in parentheses are the parameters to be passed between the application and the order_total package. The semicolon marks the end of the procedure definition.
Procedure Definition
To define a procedure, you must specify a routine name and the parameters to be passed in and out of the routine. In the order_total example, the following code defines the application-interface routine and resides in the package specification area:
PROCEDURE
get_order_total (
in_order_num IN NUMBER,
out status_code OUT VARCHAR2,
out_msg OUT VARCHAR2,
out_merch_total OUT NUMBER,
out_shipping IN OUT NUMBER,
out_taxes IN OUT NUMBER,
out_grand_total OUT NUMBER
);
The PROCEDURE statement begins the definition of the package application-interface routine get_order_total. Enclosed in parentheses are the parameters to be passed between the application and the order_total package. The semicolon marks the end of the procedure definition.