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.
D.
http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems046.htm
WRONG!! The answer is A!
A
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.
every execute is a new server call, thus “http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems046.htm”
http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems046.htm
what about green session??
edit:
every execute is a new server call, thus “public variables are initialized to their default values”
Yes, it’s A.
tested:
PL/SQL procedure successfully completed.
Num: 5
PL/SQL procedure successfully completed.
Num: 0
a
A
a
Hey Vladimir, where did you get this info “every execute is a new server call”?
In a package variable life cycle is per session.
I think he means that each exec open a new session. That’s why we got 5 and 0. => the right answere is A.
What about green session?
AND Y?
A
The pragma SERIALLY_REUSABLE indicates that the package state is needed only for the duration of one call to the server.
Help:
Serially reusable packages cannot be accessed from database triggers or other PL/SQL subprograms that are called from SQL statements. If you try, Oracle generates an error.
Why subprogram called from SQL or trigger cannot make use of the subprogram with PRAMA SERIALLY_REUSEABLE?
A is correct.
http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/13_elems046.htm
CREATE or REPLACE PACKAGE z_test_pkg1 IS
PRAGMA SERIALLY_REUSABLE;
num NUMBER := 0;
PROCEDURE init_pkg_state(n NUMBER);
PROCEDURE print_pkg_state;
END z_test_pkg1;
/
CREATE or REPLACE PACKAGE BODY z_test_pkg1 IS
PRAGMA SERIALLY_REUSABLE;
PROCEDURE init_pkg_state (n NUMBER) IS
BEGIN
z_test_pkg1.num := n;
dbms_output.put_line(‘Num: ‘ || z_test_pkg1.num);
END;
PROCEDURE print_pkg_state IS
BEGIN
dbms_output.put_line(‘Num: ‘ || z_test_pkg1.num);
END;
END z_test_pkg1;
/
——————————————————————————
——————————————————————————
SQL> SET SERVEROUTPUT ON
SQL> EXEC z_test_pkg1.init_pkg_state(5);
Num: 5
PL/SQL procedure successfully completed
SQL> EXEC z_test_pkg1.print_pkg_state;
Num: 0
PL/SQL procedure successfully completed
A
Please go to the internet sites we comply with, such as this 1, as it represents our picks in the web.
Please visit the websites we stick to, which includes this a single, as it represents our picks from the web.
Usually posts some very interesting stuff like this. If youre new to this site.
Every after in a whilst we opt for blogs that we study. Listed beneath are the most recent web-sites that we choose
usually posts some quite exciting stuff like this. If you are new to this site
although web sites we backlink to beneath are considerably not related to ours, we really feel they may be truly worth a go by, so possess a look
Wonderful story, reckoned we could combine some unrelated data, nonetheless genuinely worth taking a appear, whoa did one study about Mid East has got much more problerms too
Sites of interest we’ve a link to
always a massive fan of linking to bloggers that I love but dont get a whole lot of link appreciate from
the time to study or visit the subject material or web-sites we’ve linked to beneath the
Here is an excellent Blog You may Discover Interesting that we Encourage You
A
a
This is the awesome wonderful search system in the planet
http://google.com
A