如何使用字典视图中的信息获取有关Oracle 11g中给定包中声明的所有类型数据的信息。
答案 0 :(得分:4)
使用PL / Scope ...
alter session set plscope_settings = 'IDENTIFIERS:ALL';
...并重新编译包(在我的情况下为UTL_LOG
)...
alter package utl_log compile;
alter package utl_log compile body;
...然后查询user_identifiers
视图...
select name, type, object_name, object_type, line, col
from user_identifiers
where object_name = 'UTL_LOG'
and usage = 'DECLARATION'
and type not in ('VARIABLE','FUNCTION','FORMAL IN','FORMAL OUT','CONSTANT','PROCEDURE','FUNCTION','PACKAGE')
;
...(在我的情况下)会产生......
NAME TYPE OBJECT_ OBJECT_ LINE COL
------------------- ------- ------- ------- ---- ---
ARR_SOME_COLLECTION VARRAY UTL_LOG PACKAGE 19 6
REC_SOME_RECORD RECORD UTL_LOG PACKAGE 15 6
TYP_LOG_CODE SUBTYPE UTL_LOG PACKAGE 8 9
请注意 PL / Scope可用于任何程序单元中声明/定义的任何标识符,不仅适用于数据类型声明
答案 1 :(得分:0)
如果您想了解包的运行方式:desc PACKAGE_NAME
:
SQL> desc dbms_output
PROCEDURE DISABLE
PROCEDURE ENABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
BUFFER_SIZE NUMBER(38) IN DEFAULT
PROCEDURE GET_LINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
LINE VARCHAR2 OUT
STATUS NUMBER(38) OUT
PROCEDURE GET_LINES
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
LINES TABLE OF VARCHAR2(32767) OUT
NUMLINES NUMBER(38) IN/OUT
PROCEDURE GET_LINES
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
LINES DBMSOUTPUT_LINESARRAY OUT
NUMLINES NUMBER(38) IN/OUT
PROCEDURE NEW_LINE
PROCEDURE PUT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
A VARCHAR2 IN
PROCEDURE PUT_LINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
A VARCHAR2 IN
如果您想获取所有依赖项,请参阅ALL_DEPENDENCIES:
SQL> ed
Wrote file afiedt.buf
1 create or replace package t1_pkg
2 as
3 procedure fake_proc;
4* end t1_pkg;
SQL> /
Package created.
SQL> ed
Wrote file afiedt.buf
1 create or replace package body t1_pkg
2 as
3 procedure fake_proc
4 as
5 l_count number(10);
6 begin
7 select count(*)
8 into l_count
9 from user_objects;
10 end fake_proc;
11* end t1_pkg;
SQL> /
Package body created.
SQL> select referenced_name, referenced_type from user_dependencies where name = 'T1_PKG';
REFERENCED_NAME REFERENCED_TYPE
--------------- ------------------
STANDARD PACKAGE
USER_OBJECTS SYNONYM
T1_PKG PACKAGE
答案 2 :(得分:0)
我认为没有任何动态视图可以直接获取该信息。
我正在考虑使用REGULAR EXPRESSION查询ALL_SOURCE
以查找DATA TYPE
列中所有可能的DESCRIPTION
。将PACKAGE NAME
放在where子句中WHERE name = package_name
注意
基于其他答案,似乎有一种直接的方式,所以我的解决方案将是另一种选择。俗话说,有很多方法可以完成同样的任务,这就是其中之一。