Wednesday, July 11, 2007

Forward Declaration

PL/SQL allows for a special subprogram declaration called a forward declaration. It consists of the subprogram
specification in the package body terminated by a semicolon. You can use forward declarations to do the
following:
• Define subprograms in logical or alphabetical order.
• Define mutually recursive subprograms.(both calling each other).
• Group subprograms in a package
Example of forward Declaration:
CREATE OR REPLACE PACKAGE BODY forward_pack
IS
PROCEDURE calc_rating(. . .); -- forward declaration
PROCEDURE award_bonus(. . .)
IS -- subprograms defined
BEGIN -- in alphabetical order
calc_rating(. . .);
. . .
END;
PROCEDURE calc_rating(. . .)
IS
BEGIN
. . .
END;
END forward_pack;

No comments: