SQL 如何在 ORACLE 中显示包中的功能代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3652650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 07:26:50  来源:igfitidea点击:

How show function code from package in ORACLE?

sqloracle

提问by Michal Drozd

What is best way to show function FUNCTION1 from package PACK ?

从包 PACK 显示函数 FUNCTION1 的最佳方式是什么?

DESC PACK.FUNCTION1does not work

DESC PACK.FUNCTION1不起作用

回答by Kirill Leontev

What do you mean by saying "to show"? You can see a package body implementation this way:

你说的“展示”是什么意思?您可以通过以下方式查看包体实现:

select text 
  from all_source a 
 where a.type = 'PACKAGE BODY' 
   and a.name = 'YOUR_PACKAGE' 
 order by line asc

though you can't extract only a certain function from a package this way. You can do the same with standalone functions by setting a.type = 'FUNCTION'.

尽管您不能以这种方式从包中仅提取某个功能。您可以通过设置a.type = 'FUNCTION'.

回答by JulesLt

Well, the best way is probably using something like SQLDeveloper (or TOAD) that has a schema browser, syntax highlighting, etc OR extracting the source out into text files that you can throw into your favourite editor.

嗯,最好的方法可能是使用 SQLDeveloper(或 TOAD)之类的东西,它具有模式浏览器、语法突出显示等,或者将源提取到文本文件中,您可以将其放入您喜欢的编辑器中。

Both options beat querying and reformatting the source in USER_SOURCE just to find a function spec.

这两个选项都优于在 USER_SOURCE 中查询和重新格式化源代码以找到函数规范。

Pretty poor going on Oracle's part as DESC PACK.FUNCTION1 used to work on Oracle 7, but they switched it over to DESC PACK only.

由于 DESC PACK.FUNCTION1 曾经在 Oracle 7 上工作,因此 Oracle 的表现非常糟糕,但他们仅将其切换到 DESC PACK。

回答by Michael Pakhantsov

May be function FUNCTION1 does exists in package PACK?? Because it works.

可能是功能 FUNCTION1 确实存在于包 PACK 中??因为它有效。

  SQL> desc dbms_output.put_line
   Parameter Type     Mode Default? 
   --------- -------- ---- -------- 
   A         VARCHAR2 IN            

SQL> desc dbms_random;

SQL> 描述 dbms_random;

  Element    Type      
  ---------- --------- 
  SEED       PROCEDURE 
  VALUE      FUNCTION  
  NORMAL     FUNCTION  
  STRING     FUNCTION  
  INITIALIZE PROCEDURE 
  RANDOM     FUNCTION  
  TERMINATE  PROCEDURE 
  NUM_ARRAY  TYPE      

SQL> desc dbms_random.value

SQL> 描述 dbms_random.value

  Parameter Type   Mode Default? 
  --------- ------ ---- -------- 
  (RESULT)  NUMBER               
  (RESULT)  NUMBER               
  LOW       NUMBER IN            
  HIGH      NUMBER IN