View the Exhibit and examine the package code created by SCOTT. The execute privilege on this package is granted to green.
Examine the following sequence of commands issued by SCOTT:
What is the outcome?
A. SCOTT’S session displays 5, and then 0, greets session displays 0.
B. SCOTT’S session displays 5, and then 0; green’s session displays 5.
C. SCOTT’S session displays 5, and then 5 again, green’s session displays 0.
D. SCOTT’S session displays 5, and then 5 again; green’s session displays 5.
A is correct answer. Used following code to confirm, though users are different:
create or replace package pkg1 is
pragma serially_reusable;
num number:=0;
procedure init_pkg_state(n number);
procedure print_pkg_state;
end pkg1;
/
create or replace package body pkg1 is
pragma serially_reusable;
procedure init_pkg_state (n number) is
begin
pkg1.num:=n;
dbms_output.put_line(‘Num: ‘ || pkg1.num);
end;
procedure print_pkg_state is
begin
dbms_output.put_line(‘Num: ‘||pkg1.num);
end;
end pkg1;
/
grant execute on pkg1 to oe;
as HR user:
set serveroutput on;
exec pkg1.init_pkg_state(5);
exec pkg1.print_pkg_state;
as OE:
set serveroutput on;
exec hr.pkg1.print_pkg_state;