The global memory for
serially reusable packages is pooled in the System Global Area (SGA), not
allocated to individual users in the User Global Area (UGA). That way, the
package work area can be reused. When the call to the server ends, the memory
is returned to the pool. Each time the package is reused, its public variables
are initialized to their default values or to NULL.
Serially reusable packages cannot be accessed from database triggers
or other PL/SQL subprograms that are called from SQL statements. If you try,
the database generates an error.
A SERIALLY_REUSABLE pragma can appear in the specification of a bodiless package, or in both the specification and body of a package. The pragma cannot appear only in the body of a package.
Example Creating a Serially
Reusable Package:
CREATE PACKAGE pkg1 IS
PRAGMA SERIALLY_REUSABLE;num NUMBER := 0;
PROCEDURE init_pkg_state(n NUMBER);
PROCEDURE print_pkg_state;
END pkg1;
/
CREATE PACKAGE BODY pkg1 IS
PRAGMA
SERIALLY_REUSABLE;PROCEDURE init_pkg_state (n NUMBER) IS
BEGIN
pkg1.num := n;
END;
PROCEDURE print_pkg_state IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Num: ' || pkg1.num);
END;
END pkg1;
/
No comments:
Post a Comment