Advertisement

01.07.2008 at 06:43AM PST, ID: 23063556
[x]
Attachment Details

Purging Process is very slow

Asked by sval1411 in Oracle Database

Tags: Oracle

Hi All,
   I have a Stored Proc which purges 3 tables. But the process is
extremely slow.
The proc is below, any help will be appreciated.

CREATE OR REPLACE PROCEDURE PROC_PURGE
IS
  record_cnt NUMBER := 0;
BEGIN
  FOR rec_cur IN (SELECT trn.TRANS_ID,
                         trn.CUST
                    FROM CUSTOMER_TRAN trn
   WHERE TRUNC(gl.TRANS_DATE) < TRUNC(SYSDATE) - 14)
  LOOP
     DELETE FROM CUSTOMER_TRAN trn
             WHERE trn.TRANS_ID = rec_cur.TRANS_ID
                 AND trn.CUST = rec_cur.CUST;

       DELETE FROM CUSTOMER_ACCTS acct
             WHERE acct.TRANS_ID = rec_cur.TRANS_ID;

       DELETE FROM CUST_FUNDS fnd
             WHERE fnd.TRANS_ID = rec_cur.TRANS_ID
                AND fnd.CUST = rec_cur.CUST;

       record_cnt := record_cnt + 3;

       IF record_cnt >= 1000 THEN
          COMMIT;
            record_cnt := 0;
     END IF;
  END LOOP;

  COMMIT;

  DELETE FROM CUST_RESTORE rst
        WHERE TRUNC(rst.REST_DATE) < TRUNC(SYSDATE) - 14;
  COMMIT;

  EXCEPTION
    WHEN OTHERS THEN
        RAISE_APPLICATION_ERROR(-20001,'error'||SQLCODE||SUBSTR(SQLERRM,1,100));


END;Start Free Trial
 
Loading Advertisement...
 
[+][-]01.07.2008 at 07:03AM PST, ID: 20599908

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 07:26AM PST, ID: 20600102

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 07:39AM PST, ID: 20600212

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: Oracle
Sign Up Now!
Solution Provided By: GGuzdziol
Participating Experts: 4
Solution Grade: B
 
 
[+][-]01.07.2008 at 07:47AM PST, ID: 20600287

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 08:08AM PST, ID: 20600463

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 08:31AM PST, ID: 20600653

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 08:43AM PST, ID: 20600743

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 08:51AM PST, ID: 20600812

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 08:55AM PST, ID: 20600846

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]01.07.2008 at 09:14AM PST, ID: 20600996

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628