Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all table references from Oracle 10G PL/SQL functions and procedures? [duplicate]

How to find all table references from Oracle 10G PL/SQL functions and procedures?

I definitely can execute the following SQL statement:

select * from dba_source where text like '%tbl_c%'

but I wonder how to find all functions that call functions that refer to table used. For example I can have a function A that calls function B that uses table tbl_c. If I'll execute aforementioned SQL I'll find funciton B but then I have to execute another SQL to find A. As you know the cyclomatic complexity could be 3,4,5 levels deep or even greater.

Greatly appreciate in advance for your explanation.

like image 994
Roman Kagan Avatar asked Dec 06 '25 10:12

Roman Kagan


1 Answers

dba_dependencies is where to start. Example:

 SELECT      owner
             || '.'
             || NAME
             || ' ('
             || DECODE (TYPE,
                        'MATERIALIZED VIEW', 'MV',
                        'DIMENSION', 'DIM',
                        'EVALUATION CONTXT', 'EVALCTXT',
                        'PACKAGE BODY', 'PKGBDY',
                        'CUBE.DIMENSION', 'CUBE.DIM',
                        TYPE
                       )
             || ')' objdep,
                referenced_name
             || ' ('
             || DECODE (referenced_type,
                        'EVALUATION CONTXT', 'EVALCTXT',
                        'NON-EXISTENT CONTXT', 'NO-EXIST',
                        'PACKAGE BODY', 'PKGBDY',
                        'CUBE.DIMENSION', 'CUBE.DIM',
                        referenced_type
                       )
             || ')' refr
        FROM dba_dependencies
       WHERE owner = :usn
    ORDER BY objdep;
like image 101
Brian Avatar answered Dec 07 '25 23:12

Brian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!