2011-11-2911G新功能:PL/SCOPE-创新互联

/tupian/20230522/thread-1499223-20-1.html

创新互联公司从2013年开始,是专业互联网技术服务公司,拥有项目成都网站设计、成都网站制作、外贸网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元宽城做网站,已为上家服务,为宽城各地企业和个人服务,联系电话:028-86922220

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:同上,只是调用的地方不同。


分享文章:2011-11-2911G新功能:PL/SCOPE-创新互联
本文地址:http://scjbc.cn/article/hspjg.html

其他资讯