Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:32:29+00:00 2026-05-25T19:32:29+00:00

I’ve got a bad code duplication problem where we cannot tell which versions of

  • 0

I’ve got a bad code duplication problem where we cannot tell which versions of packages/procedures are being used. i.e. I have different packages with procedures of the same name and I need to be sure which packages are not actually being called.

I’m trying to eliminate procedures/packages of the same name which are no longer being called. I’d like to run the trace for a few weeks, combine the data and query the metadata against it and find candidates for further investigation and deactivation.

I’m looking for the equivalent of SQL Server’s sp_trace_create with sp_trace_setevent 42 to track the SP:Starting event – this would allow me to see all the stored procedures being called and then compare that to the entire inventory of stored procedures to see which ones should be investigated first for obsolescence. I have used DBMS_MONITOR.DATABASE_TRACE_ENABLE to generate trace files, but I haven’t found anything which explains how to use TKPROF to parse those files for anything but performance – nor do I even care about the statements themselves, just which routines are being used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:32:29+00:00Added an answer on May 25, 2026 at 7:32 pm

    Dont think ILO will help (does it do more than just set the module and action and log the time somewhere ?) as Cade Roux would have to modify every package and function in the database.

    One option is to switch on tracing at the database,

     ALTER SYSTEM SET sql_trace = true SCOPE=MEMORY;
    

    and use a script command to get a unique list of all the package names executed although WARNING – this will generate a lot of output and fill up disk space very rapidly – you may want to create a file of the procedures run each day and then remove the trc files and then combine the results all together to identify which ones are used.

    Also you need to ensure there is no limit on the trace file size which could prevent it logging everything and also ensure you have plenty of disk space and as you are not interested in the runtimes, you can also turn timed_statistics off to reduce the amount of logging.

     alter system set max_dump_file_size=unlimited;
     alter system set timed_statistics=false;
    

    If i look at the raw trace files created from Oracle tracing, each application specific package call procedure call appears like this

    =====================
    PARSING IN CURSOR #2 len=69 dep=0 uid=102 oct=47 lid=102 tim=1316845390611021 hv=273704950   
     ad='b0d4c728' sqlid='01qnrr4850tzq'
    BEGIN REIM_MATCH_SQL.INIT_SUMMARY_MATCH(:1, :2, :3, :4, :5, :6); END;
    END OF STMT
    PARSE #2:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,plh=0,tim=1316845390611021
    

    so you can grep for the list of package calls like this in the directory (you might have to tweak the output a little depending on the OS you are using in case the tkprof output is different)

    find . -name "*.trc" -exec grep "BEGIN " {} \; | cut -d" " -f4 | cut -d"(" -f1 | sort -u > ~/called_procedures.txt
    

    This doesnt work with functions as they can be called in the middle of SQL statements but i think for procedures, it should be ok. This will produce a file in your home directory containing the unique list of procedure calls that have run since you turned on tracing.

    I did a run of this on a directory containing 9818 trace files totalling 19GB of diskspace and it took 10 minutes on a test box running Oracle enterprise Linux 5 with 2 cores and 12GB memory – these trace files are just from repeated test runs of one program so you can imagine how quickly these will be created if you are generating for everything in a production machine.

    Then you can get a list of all pacakges/procedures in the database from sqlplus for the particular schema you are interested in

    set heading off
    set trimspool on
    set pagesize 0
    set feedback off
    spool all_procedures.txt 
    SELECT DISTINCT p.object_name||'.'||p.procedure_name
      FROM all_procedures p
      JOIN all_objects o ON (o.owner = p.owner AND o.object_name = p.object_name AND o.object_type =
     where p.owner='&owner'
     order by 1
    spool off
    

    and finally do a diff of the two to get a list of candidates

    diff all_procedures.txt called_procedures.txt
    

    Dont forget to switch off tracing when you are done

    ALTER SYSTEM SET sql_trace = false SCOPE=MEMORY;
    

    Also, you need to be careful about procedures which may only be run at certain periods like month end or year end – they may appear not to be being used but you cant be sure unless every business process is completed during the time you are monitoring.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.