11.8. Variable Declarations

You declare local subprogram variables in the declarative region between the keywords: IS and BEGIN.

PROCEDURE procedure_name(. . .)
IS
    constants, types, variables declare here.
BEGIN
    body of code.
END procedure_name;

FUNCTION function_name(. . .) RETURN some_datatype
IS
    constants, types, variables declare here.
BEGIN
    body of code.
    RETURN value_to_return;
END function_name;

The scope of a procedure or function variable is only the subprogram in which the variable is declared. The following is a package specification and body with two procedures. Each procedure has a single variable. Each procedure is autonomous. The variables NAME and MAJOR are local to their respective subprograms.

 PACKAGE students_pkg is PROCEDURE ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.