"An autonomous transaction sees all changes by hand transact.

Hello
I'm trying to reproduce designs "a stand-alone transaction sees all changes made by the main transaction" on:
Oracle® Database Application Developer's Guide - Fundamentals
10g Release 2 (10.2)
Part Number B14251-01
chapter 2 SQL Processing for Application Developers

Paragraph : Autonomous Transactions
I implemented a simple case...
create table emp_ as select * from emp

begin
  update emp_ set hiredate=hiredate+100 where empno=7934;
end;

create or replace trigger trg_emp_
after insert or update on emp_
for each row

declare
    pragma autonomous_transaction;
    emp_var emp.hiredate%type;

  begin
    select hiredate
      into emp_var
      from emp_
    where empno=:new.empno;
    dbms_output.put_line('empno: '||:new.empno);
    dbms_output.put_line('old hiredate: '||:old.hiredate);
    dbms_output.put_line('new hiredate: '||:new.hiredate);
  end;
Before any change...
SQL> select empno,hiredate from emp_;

EMPNO HIREDATE
----- -----------
5498 21/4/1982
5499 11/10/1981
5411 10/10/1981
5410 10/10/1982
7369 17/12/1980
7499 20/2/1981
7521 22/2/1981
7566 2/4/1981
7654 28/9/1981
7698 1/5/1981
7782 9/6/1981
7788 19/4/1987
7839 17/11/1981
7844 8/9/1981
7876 23/5/1987
7900 3/12/1981
7902 3/12/1981
7934 23/1/1982
After the change...
SQL> begin
  2    update emp_ set hiredate=hiredate+100 where empno=7934;
  3  end;
  4  /

empno: 7934
old hiredate: 23/01/82
new hiredate: 03/05/82

PL/SQL procedure successfully completed
According to the doc select Oracle of the autonomous transaction should not see the change to column hiredate in table in the main transaction (in the anonymous block)...

Matter what I've done wrong... ???

Thank you
SIM

Simon:

As Tubby has pointed out, your dbms_output orders do not display the selected value in the trigger. Your trigger based demonstration should look like:

SQL> SELECT * FROM t;

        ID DT
---------- -----------
         1 05-SEP-2009
         2 17-JUL-2009

SQL> CREATE TRIGGER t_ai
  2     AFTER INSERT OR UPDATE ON t
  3     FOR EACH ROW
  4  DECLARE
  5     PRAGMA AUTONOMOUS_TRANSACTION;
  6     l_dt t.dt%TYPE;
  7  BEGIN
  8     SELECT dt INTO l_dt
  9     FROM t
 10     WHERE id = :new.id;
 11     DBMS_OUTPUT.Put_Line ('ID: '||:new.id);
 12     DBMS_OUTPUT.Put_Line ('Old dt: '||:old.dt);
 13     DBMS_OUTPUT.Put_Line ('New dt: '||:new.dt);
 14     DBMS_OUTPUT.Put_Line ('Aut dt: '||l_dt);
 15  END;
 16  /

Trigger created.

SQL> UPDATE t SET dt = sysdate WHERE id = 2;
ID: 2
Old dt: 17-JUL-2009
New dt: 25-OCT-2009
Aut dt: 17-JUL-2009

1 row updated.

Thus, the transaction, select automomous doesn't see the modified value of dt.

I know you are just trying to understand transactions automomous here and would never sometihg like that in the production of right? :-)

Your trigger, as written, has some interesting side effects because of the automomous transaction. For example:

SQL> INSERT INTO t VALUES(3, sysdate - 25);
INSERT INTO t VALUES(3, sysdate - 25)
            *
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "OPS$ORACLE.T_AI", line 5
ORA-04088: error during execution of trigger 'OPS$ORACLE.T_AI'

SQL> UPDATE t SET id = 3 where trunc(dt) = TO_DATE('05-Sep-2009', 'dd-mon-yyyy');
UPDATE t SET id = 3 where trunc(dt) = TO_DATE('05-Sep-2009', 'dd-mon-yyyy')
       *
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "OPS$ORACLE.T_AI", line 5
ORA-04088: error during execution of trigger 'OPS$ORACLE.T_AI'

John

Tags: Database

Similar Questions

  • Engage in relaxation with an AUTONOMOUS transaction

    Hi all

    My question is on the trigger. say if we have a before insert trigger wrote on the employee table who agrees to pay his transaction with autonomous, so if our insert on employee statement fails, the trigger is executed as it is before the outbreak.

    Practically, I checked and found that it is not have triggered. Please clarify my understanding trigger a trigger.

    Thank you

    Vipin Kumar Rai

    It's just the way it is. If a fundamental data type is violated, it fires. If a constraint (as a non null) is violated, then he fired.

    I know that you put in comment the autonomous part - I was pointing out that your use of an autonomous transaction in the part that you said is probably wrong, unless you are trying to log on each attempt insert, regardless of whether it succeeds, and (as you saw), a trigger can not capture each insert attempt if the data type is not valid (for example). Even if she did it, insert it into your trigger would fail (assuming you have the same types of data on emp_v as on emp)

  • Pipeline raised ORA-06519 function: active autonomous transaction detected

    Hi all

    My name is John and I have a problem I need to share with you the guru and the experts. I created the following function of pipeline under user Oracle ABC:

    CREATE or replace FUNCTION SomeFunction(p_from_date DATE, p_to_date DATE) T_TAB_A RETURN pipelined
    IS
    PRAGMA autonomous_transaction;
    BEGIN
    DELETE FROM temp_rcm;

    INSERT INTO temp_rcm
    SELECT * FROM int.facility fd.
    int. Capacity co
    WHERE co.resource_name = fd.resource_name
    AND co.trade_date = fd.trade_date
    AND co.trade_date BETWEEN p_from_date AND p_to_date;

    COMMIT;

    FOR rec IN (SELECT co.*
    OF temp_rcm co
    o left join int.outage
    WE (o.flag = 'Y')
    AND o.reason_flag = 'F'
    AND o.INTERVAL = co. INTERVAL OF
    AND co.resource_name = o.resource_name)
    ORDER OF co. MEANTIME,
    Co.Name) LOOP
    pipe ROW (T_A (CRE. INTERVAL, rec.trade_date,
    Rec.resource_name, Rec.day_of_week_long, rec.working_day, rec.peak));
    END LOOP;

    RETURN;
    END SomeFunction;


    I could compile and create the function SomeFunction successfully, but when I executed the following command:

    Select * from table (SomeFunction (to_date ('01 / 01/2010 ', to_date('01/01/2010')));)

    I went with the Oracle error: ORA-06519: active autonomous transaction detected and restored

    I searched on the web, such Oracle error occurs when the function has a missing "COMMIT" or "ROLLBACK" command inside an autonomous_transaction. But the fact is that I have already included the "COMMIT"; in the function. I suspected that the error was caused by the paintings that I did against (such as int.facility and int.capacity) were all the views which belonged to another schema called int. Or is it something that miss me in the service? Thank you for your time and your help.

    Kind regards
    John

    This isn't how a ref cursor is used in general. See this thread: {: identifier of the thread = 886365}

    I can't really answer your question without knowing what kind of client you are using (Java, c#, etc.).

    However, the thread should shed a lot of light on the ref Cursor.

  • ORA-06519: active autonomous transaction detected and restored

    Hello

    I have a trigger and stored procedure of the trigger call. This stored procedure contains instructions COMMIT. So I used PRAGMA AUTONOMOUS_TRANSACTION in my trigger. I created the trigger to fire after insertion in the table. When I try to insert the data, I get the error below.

    ORA-06519: active autonomous transaction detected and restored

    Can anyone clear or correct me.

    Thank you

    Before returning in a PL/SQL block, autonomous transactions started in the block must be met (to the either committed or rolled back at the back). If this is not the case, the active autonomous transaction implicitly rolls back and this error.

    Ensure that, prior to return from an autonomous PL/SQL block, autonomous, all active transactions are explicitly committed or canceled.

  • 4gig RAM installed on ABIT, card mother VT7. BIOS sees all 4Gig, Windows XP Pro sees 3Gig. How to fix?

    Contributed the most of RAM on my motherboard ABIT VT7.  BIOS sees all 4Gig.  Windows XP Pro \Control Panel \System \General sees only 3Gig of it.  It's ALL available and all simply not shown or is for XP 4Gig limit mess with things?

    Windows XP Pro is a 32-bit operating system and can't see anymore than 3 (a little) GB of RAM. I'm stating a little is because the General system hardware (e.g. edge, videos, etc.) uses little RAM, and this number varies.

    So to use more than 3 GB of RAM, you need a 64-bit operating system. If you do not at least 8 GB, it is simply not worth the hassle with the lost devices because of 64-bit drivers do not exist or software that will simply run in a 64-bit operating system

  • Shortcuts were all changed to .lnk files.

    Shortcuts were all changed to .lnk files.  All point to the same prog (IrfanView).

    Applies to all the shortcuts through the PC, including those in Control Panel of Windows startup.

    Create a new shortcut with the right target still support IrfanView.

    I need to restore my shortcuts to point to their original targets.

    Following the questions of other users did not help.

    Edition of the file association for .lnk files makes all point to the same target.

    It seems to be a lot of tips for Vista, but not for 7.

    Just extract the first file reg on the desktop IE http://www.winhelponline.com/fileasso/lnkfix_vista.zip

    Then do this

    Click Start, and then run...

    Type regedit and press OK

    In regedit, click on file and then import it

    Locate the ".reg" file you just extract, and then press OK

    The content of this ".reg" file will be listed in the register.

    You can do the same thing for the second .reg file so that it opens in Notepad again.

    http://www.Winhelponline.com/fileasso/regfix_vista.zip

    If this post answers your question, click mark as answer .

  • my icons have all changed to DPIsnt icons and don't launch, they give me just the Wizard installation device driver, how to solve this?

    my icons have all changed to DPIsnt icons and don't launch, they give me just the Wizard installation device driver, how to solve this? It won't let me continue with the wizard, I tried to launch a game through this program (the game needs a program to help him run and stupidly, I thought it was the right one) now each icon has changed and I can't access anything chrome atm, im a novice on computers so a guide idiots to solve this would be much appreciated Thank you very much

    Hello

    Did you make any changes before the show?

    Method 1: Run a virus scan to make sure that the computer is virus-free.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx
    Note: The data files that are infected must be cleaned only by removing the file completely, which means that there is a risk of data loss.

    Method 2: Icons change incorrectly in Windows

    http://support.Microsoft.com/kb/2396571
    Note: Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base: 322756 (http://support.microsoft.com/kb/322756 /) how to back up and restore the registry in Windows.

    Method 3: When you run an .exe on a Windows XP, Windows Vista or Windows 7 computer file, the file can start another program

    http://support.Microsoft.com/kb/950505
    Note: Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base: 322756 (http://support.microsoft.com/kb/322756 /) how to back up and restore the registry in Windows.

    Let us know if that helps.

  • If your catalog contains all changes to my photos how can I give a picture of someone else without the catalog?

    This is going to sound very stupid. I'm new to Lightroom, so it's probably obvious. It is my understanding that Lightroom does not change your original photos and simply stores all changes in catalog file. So how it is when you give someone a photo you have edited that they will get the edited image if they have Lightroom and my catalog? Lightroom is some publish kind of command that creates the file, you can then specify?

    Lightroom has an export option that allows you to export to JPEG, TIF or PSD copies, and those exported copies will include all the settings made using Lightroom. You may find it useful to take the time to watch this video series, since you are new to Lightroom.

    Getting started with Lightroom cc - YouTube

    Julieanne kost lightroom - YouTube

  • If I purge the cache of RAW in Lightroom, it removes all changes applied to my photos?

    Hello everyone,

    I'm sorry maybe that this topic has already been discussed on the forum, I'm new. After reading a lot here, now I have questions !

    My 1. question is simple: if I purge the cache of RAW in Lightroom, it removes all changes applied to my photos?

    I thank ofr you your help.

    Dala

    My 1. question is simple: if I purge the cache of RAW in Lightroom, it removes all changes applied to my photos?

    # Your changes are stored in the Lightroom catalog file.

  • Flickering of the screen while the edition of tiff files makes me lose all changes.

    When you edit a tiff file it causes my screen flashes, I tried with GPU power on and off and the same behavior, if I am trying to change a slider during this flickering I lose all changes to tiff. I know what is happening to more people as I've seen on the forums, this happens to me on two different one computers a MAC Pro and the other a PC.

    For example, I go to NIK and make a change and then go back and Lightroom starts flickering / refreshing and when this happens if I'm dragging a slider it will reset all the changes to this picture.

    Please help as I am unable to use Lightroom at the moment.

    Many people have reported this problem, Adobe has recognized as a bug.  See this thread in the official forum for feedback to Adobe for workarounds: a TIFF from LightRoom 6 recharge after each change, development of potential data loss.  Don't forget to add your vote and opinion to make it more likely Adobe will give priority to a solution.

  • Is it possible to import Raw files into the LR catalog...... including all changes in an external file raw editor such as Capture One?

    Is it possible to import Raw files into the LR catalog...... including all changes in an external file raw editor such as Capture One?

    I can import the Raw file successfully, but can't see all the changes that have been applied in Capture One. IM assuming not, but just to check.

    Your assumption is correct, Capture One, Lightroom and other third party raw processors have their own exclusive process and profiles to render the raw data.

    They do not make permanent changes to the raw data and save changes to a .xmp file or to a Lightroom catalog file.

  • best way to remove all changes

    What is the best way to remove all changes that were made to an image in Camera Raw, to get the picture to the way it was originally?

    I'm surprised! I use Lightroom most of the time, and that's what the reset button. You can do this in bridge. Right-click on the image, then choose the development-> erase settings parameters. As an alternative, you can use your file system browser to delete the XMP files.

  • Is it possible to invoke() 'All change' in find/replace?

    Hi all

    Is it possible to invoke() 'All change' in find/replace?

    Kind regards

    Cognet

    Maybe, maybe not (()) - but it's not necessary. changeText() is already a whole change.

    (*) I guess not because invoke() concerns only the menu commands.

  • Projects PPro CS4 will open a newly installed PPro CS6 and all changes will be kept?

    PPro CS4 will be retained in projects in PPro CS6 load process and will be all changes?

    Most of the time - Yes. You may lose some settings and effects, however, because such things changed a lot as a management of certain types of images.

    Mylenium

  • autonomous transaction block of exception

    Hi friends,

    Can you tell me if it is possible to use an autonomous transaction block exception?

    If so, how? Please provide me with a guide line

    thnx

    ROY wrote:
    Hi friends,

    Can you tell me if it is possible to use an autonomous transaction block exception?

    If so, how? Please provide me with a guide line

    You cannot use an autonomous transaction directly in the exception block:

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_dummy number;
      3  begin
      4    select a into v_dummy from testtab where a = -1;
      5  exception
      6    when no_data_found then
      7      declare
      8        pragma autonomous_transaction;
      9      begin
     10        insert into testtab (a) values (-1);
     11      end;
     12      raise;
     13* end;
    SQL> /
          pragma autonomous_transaction;
                 *
    ERROR at line 8:
    ORA-06550: line 8, column 14:
    PLS-00710: PRAGMA AUTONOMOUS_TRANSACTION cannot be specified here
    

    but, if it is declared in a procedure you can call it the exceptional block...

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_dummy number;
      3    procedure insertit is
      4      pragma autonomous_transaction;
      5    begin
      6      insert into testtab (a) values (-1);
      7      commit;
      8    end;
      9  begin
     10    select a into v_dummy from testtab where a = -1;
     11  exception
     12    when no_data_found then
     13      insertit;
     14      raise;
     15* end;
    SQL> /
    declare
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 14
    

    or

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_dummy number;
      3  begin
      4    select a into v_dummy from testtab where a = -1;
      5  exception
      6    when no_data_found then
      7      declare
      8        procedure insertit is
      9          pragma autonomous_transaction;
     10        begin
     11          insert into testtab (a) values (-1);
     12          commit;
     13        end;
     14      begin
     15        insertit;
     16      end;
     17      raise;
     18* end;
    SQL> /
    declare
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 17
    

Maybe you are looking for

  • Satellite Pro M10: Need Wlan drivers for 802. 11 G

    I need different drivers after formatting the HARD disk an important is the driver for the WiFi card.The only one I can find is B I need a to G hope you can help, the conection keeps falling and makes me crazy x

  • Pavilion 27bw monitor power button is unresponsive

    This has happened once before and I forgot how I fixed. No message power button lock or anything. I tried to unplug for a few minutes, she held down for a minute, nothing. I get static when I touch it sometimes but managed to solve this last time. Su

  • Problem during the call to an external web service - CRM 2013

    Hello everyone. It's my scenario: I do a real-time CRM data integration with other software. I have deployed several plugins, for the most part in messages to create/update, for entities I want to synchronize. The developers of other software gave me

  • Impossible to get WebVPN working on chassis VPN 3030

    This v4.1.7P chassis works perfectly for our installation of the client vpn Cisco, no problem. We have decided to extend its usefulness by turning on and configuring WebVPN. I did it on a router IOS, Cisco 1841, works very well, so I'm following the

  • NetBook S10-2 wireless

    Hello.  Today my S10-2 Netbook wireless function does not work.  I've updated the drivers to uninstall them, but not luck.  Also, I press FN + F5 and I have no devices listed.  What can I do or check? Thank you.