温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

2011-11-29 11G新功能:PL/SCOPE

发布时间:2020-08-08 21:42:17 来源:ITPUB博客 阅读:175 作者:hanaka 栏目:关系型数据库

http://www.itpub.net/thread-1499223-20-1.html

197楼

我在当前会话把PL/Scope打开:

ALTER SESSION SET plscope_settings='identifiers:all'
/

然后我创建了这个包头:

CREATE OR REPLACE PACKAGE plch_pkg
IS
   PROCEDURE do_stuff;
END plch_pkg;
/

下列哪些查询实现了一个包体,从而使得下列的查询:

SELECT name, usage
  FROM user_identifiers
WHERE     object_name = 'PLCH_PKG'
       AND type IN ('PROCEDURE', 'FUNCTION')
ORDER BY usage
/

会输出这些结果:

NAME       USAGE      
---------- -----------
DO_STUFF   CALL      
DO_STUFF   DECLARATION
DO_STUFF   DECLARATION
DO_STUFF   DEFINITION
DO_STUFF   DEFINITION

(A)

CREATE OR REPLACE PACKAGE BODY plch_pkg
IS
   PROCEDURE do_stuff (number_in IN NUMBER)
   IS
   BEGIN
      NULL;
   END do_stuff;
   PROCEDURE do_stuff
   IS
   BEGIN
      NULL;
   END do_stuff;
END plch_pkg;
/
SQL> SELECT name, usage
  2    FROM user_identifiers
  3  WHERE     object_name = 'PLCH_PKG'
  4         AND type IN ('PROCEDURE', 'FUNCTION')
  5  ORDER BY usage
  6  /
NAME                                                                             USAGE
-------------------------------------------------------------------------------- -----------
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DEFINITION
DO_STUFF                                                                         DEFINITION
SQL>

(B)

CREATE OR REPLACE PACKAGE BODY plch_pkg
IS
   PROCEDURE do_stuff
   IS
   BEGIN
      NULL;
   END do_stuff;
END plch_pkg;
/
SQL> 
SQL> SELECT name, usage
  2    FROM user_identifiers
  3  WHERE     object_name = 'PLCH_PKG'
  4         AND type IN ('PROCEDURE', 'FUNCTION')
  5  ORDER BY usage
  6  /
NAME                                                                             USAGE
-------------------------------------------------------------------------------- -----------
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DEFINITION
SQL>

(C)

CREATE OR REPLACE PACKAGE BODY plch_pkg
IS
   PROCEDURE do_stuff (number_in IN NUMBER)
   IS
   BEGIN
      NULL;
   END do_stuff;
   PROCEDURE do_stuff
   IS
   BEGIN
      do_stuff (1);
   END do_stuff;
END plch_pkg;
/
SQL> SELECT name, usage
  2    FROM user_identifiers
  3  WHERE     object_name = 'PLCH_PKG'
  4         AND type IN ('PROCEDURE', 'FUNCTION')
  5  ORDER BY usage
  6  /
NAME                                                                             USAGE
-------------------------------------------------------------------------------- -----------
DO_STUFF                                                                         CALL
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DEFINITION
DO_STUFF                                                                         DEFINITION
SQL>

(D)

CREATE OR REPLACE PACKAGE BODY plch_pkg
IS
   PROCEDURE do_stuff (number_in IN NUMBER)
   IS
   BEGIN
      NULL;
   END do_stuff;
   PROCEDURE do_stuff
   IS
   BEGIN
      NULL;
   END do_stuff;
BEGIN
   do_stuff (1);
END plch_pkg;
/
SQL> SELECT name, usage
  2    FROM user_identifiers
  3  WHERE     object_name = 'PLCH_PKG'
  4         AND type IN ('PROCEDURE', 'FUNCTION')
  5  ORDER BY usage
  6  /
NAME                                                                             USAGE
-------------------------------------------------------------------------------- -----------
DO_STUFF                                                                         CALL
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DECLARATION
DO_STUFF                                                                         DEFINITION
DO_STUFF                                                                         DEFINITION
SQL>

答案说明在202楼

2011-11-29 答案CD

A:在此选项中do_stuff被重载,所以DECLARATION 和 DEFINITION的显示行数是正确的。但是,并没有对do_stuff的调用。

B:为了使得DECLARATION 和 DEFINITION各显示两行,do_stuff必须被重载。

C:既有重载又有调用,正确。

D:同上,只是调用的地方不同。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI