check if oracle function exists
I have an Oracle schema, where I have some functions and some packages that have functions inside.
How can I test if a string value is a function name in my schema, and if it is, return the function result, or if it's not a function to return the string value?
I tried to start from
SELECT * FROM ALL_OBJECTS
WHERE OBJECT_TYPE IN ('FUNCTION','PROCEDURE','PACKAGE','PACKAGE_BODY')
but this does not return the function names from inside the packages. Th开发者_如何学Goank you!
Use the view ALL_PROCEDURES.
The column OBJECT_NAME will show you the name of standalone functions and procedures, and packages names. The column PROCEDURE_NAME will show you the names of functions and procedures inside a package.
As you're only interested in functions you might be better off using ALL_ARGUMENTS. This views records the parameters used by a procedure or function. If a given program unit has a POSITION with a value of zero, that indicates the return value for a function.
精彩评论