Let's say I have an ORACLE schema with contains a package. That package defines types, functions, procedures, etc:
CREATE PACKAGE...
DECLARE
FUNCTION ...
PROCEDURE ...
END;
Is there a query I can execute to get the definitions of those individual objects, without the wrapping package?
If you need the procedures/functions of the package, you can use
user_procedures
:Select object_name, procedure_name From user_procedures Where object_name = 'PACKAGE_TEST';
returns
To get the parameters, select from
user_arguments
.If you want the code for your packages/procedures/functions, use
user_source
for objects of your user,all_source
for objects your user has grants for, anddba_source
for all objects:If you created the procedure
your_test
before:it returns
It is possible to retrieve the signatures of individual methods from the data dictionary. The relevant view is USER/ALL/DBA_ARGUMENTS.
There are a couple of snags to watch out for. If an argument has a postition of 0 it is the return value of a function not a parameter. If the parameter is a complex type (such as a nested table or PL/SQL record) it will appear multiple times, with each layer incrementing the
data_level
.The following query joins arguments with their owning procedures. I am excluding the entries in USER_PROCEDURES at the package level (that is,
subprogram_id=0
) and the entries in USER_ARGUMENTS for the lower levels of complex_type (that is,data_level > 0
). The query also handles procedures without any parameters.I could have selected other useful information from USER_ARGUMENTS such as IN_OUT or whether the parameter is DEFAULTED, but I figured it scrolled enough already.