http://www.itpub.net/thread-1499223-12-1.html
119楼
执行下列语句之后,我的屏幕上会显示什么?
CREATE OR REPLACE PACKAGE plch_pkg IS g_public NUMBER := 1; PROCEDURE do_stuff; FUNCTION get_stuff RETURN NUMBER; END; / CREATE OR REPLACE PACKAGE BODY plch_pkg IS PROCEDURE do_stuff IS BEGIN DBMS_OUTPUT.put_line (g_public); END; FUNCTION get_stuff RETURN NUMBER IS BEGIN do_stuff; RETURN g_public + 1; END; BEGIN DBMS_OUTPUT.put_line (g_public); g_public := 2; END; / BEGIN DBMS_OUTPUT.put_line (plch_pkg.get_stuff); plch_pkg.g_public := plch_pkg.get_stuff; DBMS_OUTPUT.put_line (plch_pkg.get_stuff); END; /
(A)
1
(B)
1 2
(C)
1 2 3
(D)
1 2 3 4
(E)
1 2 3 3 4
(F)
1 2 3 2 3 4
实测答案为F
SQL> Package created Package body created 1 2 3 2 3 4 PL/SQL procedure successfully completed SQL>
答案说明在125楼
2011-11-8 答案F.
包头声明的初始值先于包体。包体第一次被调用时会执行初始化代码,因而将包头里面的初始值覆盖了。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。