oracle 如何检查程序包中是否存在程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11436432/
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
How can I check if a procedure exists in a package?
提问by FireVortex
I have packages with procedures, which are used in many places and in some places I need slightly different procedures, e.g. updating one more column.
我有带有程序的包,它们在很多地方使用,在某些地方我需要稍微不同的程序,例如再更新一列。
I thought that I could create an extra package, which would contain some but not all of the procedures.
我想我可以创建一个额外的包,其中包含一些但不是全部的程序。
Is there any way to check in an if
statement directly in scripts, that if there does not exist procedure in the extra package, to fall back on the standard package?
有没有办法if
直接在脚本中签入语句,如果额外包中不存在过程,则退回到标准包?
回答by Bob Jarvis - Reinstate Monica
You should be able to obtain this information from the DBA_PROCEDURES view:
您应该能够从 DBA_PROCEDURES 视图中获取此信息:
SELECT *
FROM SYS.DBA_PROCEDURES
WHERE OBJECT_TYPE = 'PACKAGE' AND
OBJECT_NAME = '<your package name>' AND
PROCEDURE_NAME = '<your procedure name>'
If this returns a row the procedure you're interested in exists in the package. If you get a NO_DATA_FOUND exception it means the procedure doesn't exist in the package.
如果这返回一行,则您感兴趣的过程存在于包中。如果您收到 NO_DATA_FOUND 异常,则表示程序包中不存在该过程。
Share and enjoy.
分享和享受。
回答by Emil G
Doesn't the user that is querying SYS.DBA_PROCEDURES need special privileges? Maybe querying SYS.User_Objects requires less permissions?
查询 SYS.DBA_PROCEDURES 的用户不需要特殊权限吗?也许查询 SYS.User_Objects 需要较少的权限?
select * from SYS.User_Objects where object_type = 'PACKAGE';
回答by Andre Morata
You may also try
你也可以试试
SELECT text FROM all_source WHERE name = 'PACKAGE' ORDER BY line;
Worked for me...
对我来说有效...
回答by Santosh Chaurasia
select * from USER_OBJECT where object_type='PACKAGE' AND OBJECT_NAME ='<YOUR PACKAGE NAME>'