开发者

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

This question already has an answer here: Oracle query that will list of the database objects referenced by a view (1 answer) Closed 8 years ago. 开发者_运维技巧

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.


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;


I'd prefer to use ALL_DEPENDENCIES when looking for object references rather than ALL_SOURCE. Adding to a hierarchical query, you could get what ever you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜