SQL>
SQL> CREATE TABLE keepcount (counter INTEGER);
Table created.
SQL>
SQL> INSERT INTO keepcount VALUES (1);
1 row created.
SQL>
SQL> CREATE OR REPLACE FUNCTION updcount RETURN INTEGER
2 IS
3 BEGIN
4 UPDATE keepcount SET counter = counter + 1;
5 RETURN 1;
6 END;
7 /
Function created.
SQL>
SQL> CREATE OR REPLACE PACKAGE demo
2 AS
3 PRAGMA SERIALLY_REUSABLE;
4 global_x PLS_INTEGER := updcount;
5 END;
6 /
Package created.
SQL>
SQL> CREATE OR REPLACE PACKAGE demo2
2 AS
3 PRAGMA SERIALLY_REUSABLE;
4 FUNCTION global_x RETURN PLS_INTEGER;
5 END;
6 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY demo2
2 AS
3 PRAGMA SERIALLY_REUSABLE;
4 g_global_x PLS_INTEGER := updcount;
5 FUNCTION global_x RETURN PLS_INTEGER
6 IS BEGIN RETURN g_global_x; END;
7 END;
8 /
Package body created.
SQL>
SQL> DROP TABLE keepcount;
Table dropped.
SQL>
|