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

[英]how to print out the definition of a procedure in Oracle?


Is there a way in oracle to see what a procedure's structure is? I'm trying to log and am running procedures and wanted to store the actual procedure structure in my log.

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

3 个解决方案

#1


15  

You could query the ALL_SOURCE table

您可以查询ALL_SOURCE表

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

If you are dealing with a procedure that is inside a package

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

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

will give you the text of the package body. You could also get the text of the package specification using a TYPE of "PACKAGE"

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

#2


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 )

#3


4  

dbms_metadata package, get_ddl function, perhaps?

dbms_metadata包,get_ddl函数,也许?

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/08/23/da09cc5ea61d1f1f1ba2acead78466ed.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号