DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: trying to figure out what a PL/SQL package is doing

  1. #1
    Join Date
    Mar 2005
    Posts
    143

    trying to figure out what a PL/SQL package is doing

    I company has this PL/SQL package that is cleaning up tables. I have been assigned the task of figuring out why it deletes what it deletes. I was wondering if any one can help me. I have figured out so far what tables it is deleting but I don't know what stuff it is deleting. For example it deletes from a table ps_message_log where process_instance = :v_prcs but I don't know what :v_prcs means, I would figure that earlier in the code it declares what :v_prcs means I just can't find in the code where it does that. I have attached the code. Any help would be GREATLY appreciated.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    ":v_prcs" is a SQL variable. It should be added to the parameter list for the zz_cleanup_report_purge_table stored procedure.

    Get rid of the WHEN OTHERS clause! If you get a fatal error, then you should fix the fatal error!

    Code:
    EXCEPTION
        WHEN NO_DATA_FOUND then
            --zz_dbms_output('No Child!');
            return null;
        WHEN OTHERS then
            zz_dbms_output('Hmmm, needs debugging! '||SQLERRM);
            return null;
    --
    END determine_nvs_expiration;
    If you want to know what is being deleted use DBMS_OUTPUT to print the delete code along with SQL%ROWCOUNT to see how many rows were deleted.

    Code:
    v_sqlstmt := 
    'delete ps_message_log where process_instance = :v_prcs';
    	  execute immediate v_sqlstmt 
             using v_prcsinstance;
    Also this code is just pointless! Without is you will get better error messages.

    Code:
    EXCEPTION
      WHEN OTHERS then raise_application_error
    (-20000, SQLERRM, TRUE);
    --
    END zz_populate_report_purge;
    I don't mean to be hash, but there are some serious issues with this code that need to be addresses. Get a copy of Steven Feuerstein's PL/SQL Best Practices and read it twice and you will see what I mean.
    Last edited by gandolf989; 04-11-2007 at 10:46 AM.

  3. #3
    Join Date
    Mar 2005
    Posts
    143
    thanks for the help. I was told the creator of this code is no longer with the company. Who ever wrote it left no documentation. I was assigned the fun task of looking at it. Having no pl/sql knowledge I am banging my head against the wall.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width