Solved

ORA-06519: active autonomous transaction detected and rolled back

Posted on 2006-06-12
6
4,478 Views
Last Modified: 2007-12-19
I keep getting this message in a package i created...
here is the pkg

CREATE OR REPLACE PACKAGE pkg_check_po
AS
   FUNCTION check_po_amount (p_invoice_id NUMBER, p_unid NUMBER)
      RETURN NUMBER;

   PROCEDURE change_approver (p_invoice_id IN NUMBER);

   PROCEDURE add_note (
      p_invoice_id   IN   NUMBER,
      p_unid         IN   NUMBER,
      p_status_id    IN   NUMBER,
      p_note         IN   VARCHAR2
   );
END;
/
----------------------
AND THE PKG BODY
-----------------------

/* Formatted on 2006/06/12 15:50 (Formatter Plus v4.8.5) */
CREATE OR REPLACE PACKAGE BODY pkg_check_po
AS
   FUNCTION check_po_amount (p_invoice_id NUMBER, p_unid NUMBER)
      RETURN NUMBER
   IS
      PRAGMA AUTONOMOUS_TRANSACTION;

      CURSOR po_check_cursor
      IS
         SELECT *
           FROM invoice_coding
          WHERE invoice_id = p_invoice_id AND coding_type_id = 3;

      po_check_row                 po_check_cursor%ROWTYPE;
      v_needs_different_approval   NUMBER                    := 0;
      v_amount_available           NUMBER                    := NULL;
   BEGIN
      OPEN po_check_cursor;

      LOOP
         FETCH po_check_cursor
          INTO po_check_row;

         EXIT WHEN po_check_cursor%NOTFOUND;

         SELECT NVL (po_line_amount_avail (po_check_row.po_number,
                                           po_check_row.po_line_id
                                          ),
                     0
                    )
           INTO v_amount_available
           FROM DUAL;

         DBMS_OUTPUT.put_line (   po_check_row.amount
                               || 'mmmmm'
                               || v_amount_available
                              );

         IF po_check_row.amount > v_amount_available
         THEN
            v_needs_different_approval := 1;
--          change_approver (p_invoice_id);
            pkg_check_po.add_note
               (p_invoice_id,
                p_unid,
                9,
                   'PO Line '
                || po_check_row.po_line_number
                || ' for PO Number '
                || po_check_row.po_number
                || ' was coding to an amount greater than the amount available for that line.'
               );
         END IF;
      END LOOP;

      CLOSE po_check_cursor;

      RETURN v_needs_different_approval;
   EXCEPTION
      WHEN OTHERS
      THEN
         RAISE;
   END;

   PROCEDURE change_approver (p_invoice_id IN NUMBER)
   AS
      PRAGMA AUTONOMOUS_TRANSACTION;
      v_new_approver   NUMBER := NULL;
-- this is who the invoice will go to so they can revise the PO
   BEGIN
      SELECT unid
        INTO v_new_approver
        FROM po_overage_approver;

      UPDATE invoices
         SET pending_approval_from_unid = v_new_approver,
             status_id = 9
       WHERE invoice_id = p_invoice_id;

      COMMIT;
   END;

   PROCEDURE add_note (
      p_invoice_id   IN   NUMBER,
      p_unid         IN   NUMBER,
      p_status_id    IN   NUMBER,
      p_note         IN   VARCHAR2
   )
   AS
      PRAGMA AUTONOMOUS_TRANSACTION;
   BEGIN
      INSERT INTO invoice_notes
                  (invoice_id, notes, unid, status_id, note_timestamp
                  )
           VALUES (p_invoice_id, p_note, p_unid, p_status_id, SYSDATE
                  );

      COMMIT;
   END;
END;
/

I dont know why it keeps occurring...i tried taking out the items i thought were causing it but i still get the error
0
Comment
Question by:jduawa
  • 2
  • 2
  • 2
6 Comments
 
LVL 25

Accepted Solution

by:
jrb1 earned 500 total points
ID: 16889867
Do you need the AUTONOMOUS_TRANSACTION in check_po_amount?  If you do, try a commit before the end of the procedure--after the line

CLOSE po_check_cursor;
0
 
LVL 1

Author Comment

by:jduawa
ID: 16890805
I am not sure where i need the autonomous transaction pragmas...I am not sure what it even does, I am trying to understand more behind the error, so i know how to handle it in the future...I am not sure which transaction it thinks is autonomous
0
 
LVL 25

Expert Comment

by:jrb1
ID: 16891470
Every block that uses the autonomous_transaction needs to have a commit or rollback before leaving that block.

You might want to read this:

http://asktom.oracle.com/~tkyte/autonomous/index.html

0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 16

Expert Comment

by:MohanKNair
ID: 16891849
>> I keep getting this message in a package i created...

What is the Error message?
0
 
LVL 1

Author Comment

by:jduawa
ID: 16893737
>> I keep getting this message in a package i created...

>>>What is the Error message?

ORA-06519: active autonomous transaction detected and rolled back
0
 
LVL 16

Expert Comment

by:MohanKNair
ID: 16893859
>> FUNCTION check_po_amount (p_invoice_id NUMBER, p_unid NUMBER)

As jrb1 pointed out, rollback/commit is missing in

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question