Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of all functions and procedures in an Oracle database

I'm comparing three Oracle schemas.

I want to get a list of all the functions and procedures used in each database. Is this possible via a query? (preferably including a flag as to whether they compile or not)

Ideally it would be great to have a single query with a flag that states whether the function/procedure is in each schema. But even just the first bit would be better than manually inspecting each schema.

like image 636
AJM Avatar asked Nov 30 '09 12:11

AJM


People also ask

How do you check the procedures in a schema?

SELECT [schema] = SCHEMA_NAME([schema_id]), name FROM sys. procedures; For a specific database, you can just change the context to that database first, or change Marc's query slightly (my queries are no good in this case because they rely on functions that are context-sensitive):

What are procedures and functions in Oracle?

A procedure is a subprogram that performs a specific action. You specify the name of the procedure, its parameters, its local variables, and the BEGIN-END block that contains its code and handles any exceptions. A function is a subprogram that computes and returns a value.


2 Answers

SELECT * FROM ALL_OBJECTS WHERE OBJECT_TYPE IN ('FUNCTION','PROCEDURE','PACKAGE') 

The column STATUS tells you whether the object is VALID or INVALID. If it is invalid, you have to try a recompile, ORACLE can't tell you if it will work before.

like image 106
Erich Kitzmueller Avatar answered Sep 22 '22 08:09

Erich Kitzmueller


Do a describe on dba_arguments, dba_errors, dba_procedures, dba_objects, dba_source, dba_object_size. Each of these has part of the pictures for looking at the procedures and functions.

Also the object_type in dba_objects for packages is 'PACKAGE' for the definition and 'PACKAGE BODY" for the body.

If you are comparing schemas on the same database then try:

select * from dba_objects     where schema_name = 'ASCHEMA'       and object_type in ( 'PROCEDURE', 'PACKAGE', 'FUNCTION', 'PACKAGE BODY' ) minus select * from dba_objects  where schema_name = 'BSCHEMA'    and object_type in ( 'PROCEDURE', 'PACKAGE', 'FUNCTION', 'PACKAGE BODY' ) 

and switch around the orders of ASCHEMA and BSCHEMA.

If you also need to look at triggers and comparing other stuff between the schemas you should take a look at the Article on Ask Tom about comparing schemas

like image 22
Philip Schlump Avatar answered Sep 24 '22 08:09

Philip Schlump