Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, MD.

Asked: June 08, 2009 - 3:01 pm UTC

Last updated: June 11, 2009 - 11:04 am UTC

Version: 10.2.0.3

Viewed 1000+ times

You Asked

Tom,

I would like to provide a utility/script to my development team that would allow them to compare package dependencies by using all_dependencies and then searching for a similar result string that might come from another package i.e. Here is the all_dependencies output from package A. Lets search other packages in that schema for similar or exact output from all_dependencies. The task at hand is to identify potential redundant procedures or functions across different packages. Any ideas?

and Tom said...

... The task at hand is to identify potential redundant procedures or functions across different packages. ...

that seems like a "whacky" way - I don't know of anything other than documenting what you have to determine that. Just because I use emp and dept and you use emp and dept and she uses emp and dept - doesn't mean we are doing the same thing.

And further, it would seem to me that it would miss almost everything. Say all three of us use EMP and DEPT - but we also use dozens of other things - all mutually exclusive from eachother (all my object dependencies start with 'A', yours with 'B' and hers with 'C' - nothing in common). Also - suppose I stole your routines dealing with emp and dept, after you stole them from her. We have that redundant code - but you'll never know.


In short - because we share common dependencies - doesn't mean anything. Because we don't share many common dependencies - doesn't mean anything. You have to look at and catalog both.


could I write a query that gives you this information? Sure, we could set up a threshold that "if N dependent objects match - we are to be considered 'similar'" and pass in N - but I don't see the point.

And it would be a very expensive query to compute.

here is a start for you...


ops$tkyte%ORA10GR2> with t
  2  as
  3  (
  4  select owner, name, referenced_owner, referenced_name, referenced_type ,
  5         count(*) over (partition by owner, name, type) cnt
  6    from all_dependencies
  7   where owner <> 'SYS'
  8     and referenced_owner <> 'SYS'
  9     and type = 'PACKAGE BODY'
 10  )
 11  select a.owner||'.'||a.name a,
 12         b.owner||'.'||b.name b,
 13         a.cnt, b.cnt, count(*) cnt
 14    from t a, t b
 15   where a.referenced_owner = b.referenced_owner
 16     and a.referenced_name = b.referenced_name
 17     and a.referenced_type = b.referenced_type
 18     and (a.owner <> b.owner or a.name <> b.name)
 19   group by a.owner, a.name,
 20            b.owner, b.name,
 21                    a.cnt, b.cnt
 22  having count(*) >= 15
 23   order by a.owner, a.name,
 24            b.owner, b.name
 25  /

A                              B                                     CNT        CNT        CNT
------------------------------ ------------------------------ ---------- ---------- ----------
CTXSYS.CTX_CLS                 CTXSYS.DRVDDL                          21         42         15
CTXSYS.CTX_CLS                 CTXSYS.DRVODM                          21         33         18
CTXSYS.CTX_DDL                 CTXSYS.DRISGP                          24         20         15
CTXSYS.CTX_DDL                 CTXSYS.DRISPL                          24         22         17

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

I agree

Michael Dallman, June 10, 2009 - 10:58 pm UTC

Complete documentation is the best solution no doubt. We have a legacy of not doing that but have implemented some new standards to put us where we need to be. I was looking for some mechanism to compensate for past bag practices. I'll take your suggestion and run with it. Thanks for your time.

One more question

Michael Dallman, June 11, 2009 - 10:06 am UTC

I assume the "N" value is on line 22?
Tom Kyte
June 11, 2009 - 11:04 am UTC

yes.

More to Explore

Analytics

Analytic SQL got you confused? Check out Connor McDonald's complete video course.