Variables / Collections / Cursors declared in the specification of the package are global to the session.
We are going to create a sample package to check the scope of the variable defined in the package specification.
Package CREATE OR REPLACE PACKAGE test_scope IS
v_global_char VARCHAR2(300);
FUNCTION test_func(v_char VARCHAR2) RETURN BOOLEAN;
END test_scope;
CREATE OR REPLACE PACKAGE BODY test_scope IS
FUNCTION test_func(v_char VARCHAR2) RETURN BOOLEAN IS
BEGIN
v_global_char := v_char;
RETURN TRUE;
END;
END test_scope;
Assigning and checking the value in the same session SQL>
SQL> SET serveroutput ON;
SQL> DECLARE
2 v_test BOOLEAN;
3 BEGIN
4 v_test :=test_scope.test_func('Oracle 11g PL/SQL Programming');
5 END;
6 /
PL/SQL procedure successfully completed
SQL> BEGIN
2 dbms_output.put_line(test_scope.v_global_char);
3 END;
4 /
Oracle 11g PL/SQL Programming
PL/SQL procedure successfully completed
SQL>
Checking the Assigned Value in different session SQL> set serveroutput on;
SQL>
SQL> BEGIN
2 dbms_output.put_line(test_scope.v_global_char);
3 END;
4 /
PL/SQL procedure successfully completed
SQL>
So whatever the value stored in the global variable of package specification exist until the session expires.