如何在Oracle中打印出过程的定义?

时间:2011-08-23 20:45:11

标签: sql oracle plsql

在oracle中有没有办法看到程序的结构是什么?我正在尝试记录并正在运行过程,并希望将实际的过程结构存储在我的日志中。

3 个答案:

答案 0 :(得分:18)

您可以查询ALL_SOURCE

SELECT text 
  FROM all_source
 WHERE owner = <<owner of procedure>>
   AND name  = <<name of procedure>>
 ORDER BY line

如果您正在处理包中的过程

SELECT text 
  FROM all_source
 WHERE owner = <<owner of procedure>>
   AND name  = <<name of procedure>>
   AND type  = 'PACKAGE BODY'
 ORDER BY line

将为您提供包体的文本。您还可以使用TYPE“PACKAGE”

获取包规范的文本

答案 1 :(得分:5)

SELECT TEXT, LINE FROM ALL_SOURCE WHERE 
    NAME = UPPER('$name') -- the table also has an owner field to track the user
    ORDER BY TYPE, -- type is generally procedure, but there are functions and 
                   -- more complex structures as well, such as PACKAGE
    TO_NUMBER( LINE )

答案 2 :(得分:4)

dbms_metadata packageget_ddl function,也许?

SELECT dbms_metadata.get_ddl('PROCEDURE','<yourproc>','<schema>') FROM dual;