Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ORA-06519: active autonomous transaction detected and rolled back

Posted on 2006-06-12
6
Medium Priority
?
4,534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 25

Accepted Solution

by:
jrb1 earned 2000 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

636 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