Oracle 12c PL/SQL – How to Perform Textual Search Over All Code

oracleoracle-12coracle-sql-developerplsql

I want to do a text search over all PL/SQL functions/procedures in my DB to see which code is calling a particular function. Is there a tool in SQL Developer for that, or a meta-table under the system schema storing function code? A textual dump of the schema would help as well.

Best Answer

Provided that the following is true:

1) The function is NOT in a package
2) The function call is NOT dynamic SQL

Then you can simply see what its dependencies are from dba_dependencies:

SELECT * 
  FROM dba_dependencies 
 WHERE referenced_owner = 'MYOWNER' AND referenced_name = 'MYOBJECT';

Otherwise, you can check dba_source:

SELECT * 
  FROM dba_source 
 WHERE upper(text) like '%MYOWNER.MYOBJECT%';

To view the source for all objects for a schema:

SELECT * 
  FROM dba_source 
 WHERE owner = 'MYOWNER'
 ORDER BY type, name, line;