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)

Tags: Database

Similar Questions

  • 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
    
  • 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.

  • "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

  • How to stop the acquisition with a relaxation with the NI PCIe-6323

    Hi all

    I wonder if it is possible to stop data acquisition or pcie-6323 with a trigger pulse the same way that I begin to acquire samples with a finished sample mode trigger pulse.

    Thanks in advance

    M.

    The samplesPerChannel that you can show what the sample clock configuration defines the total number of samples for the acquisition of finishes.  In your case, you will read the data previously triggered so permanently in force this setting really only sets the size of the buffer.  If you want to just be large enough to avoid overtaking (although...) If the window you buy is potentially very short, you might want to explicitly configure the size of the buffer to something bigger and maintain the value of samplesPerChannel down so that the reference trigger can be accepted earlier).

    The numberOfSamples you specify when you start the player defines the number of samples for the next call for reading.  If you can read the small windows of streaming data to avoid having a blocking with a large timeout call.  If you do not want to change the time-out period, it is a property of the DAQStream class.

    The "continuous" examples (e.g. this one) should show how you can read back data asynchronous as it is acquired.  Your configuration looks more like a "continuous" example

    Since you want to start and stop using the same line as the trigger, perhaps an alternative to the evolution of the default read pointer would be to set up a central task of analog input with a relaxing break.  The caveat to this is that the break does not stop at the task and as soon as the line goes back to you will begin to acquire the data again - I would say using a meter to separate groups of samples in the buffer zone continued.  If you wish to purchase multiple windows of data in short succession well, then I would go with that instead to avoid having to restart the task (and potentially Miss samples during the restart of the task).

    Best regards

  • BEFORE the UPDATE of relaxation with time stamp does not work as expected

    We have a scenario where I check update operations on a table.

    I created a before update TRIGGER, so that every time he goes an update on the main table statement, one before the image of the lines is captured in the table of audit with timestamp.

    Since it is before updating, ideally the audit table timestamp (TRG_INS_TMST) should be less main table timestamp (IBMSNAP_LOGMARKER) VALUE, I mean TRIGGER should happen before the update.

    (I could understand in a way that the UPDATE statement is formulated with SYSTIMESTAMP earlier before the TRIGGER is evaluated and so UPDATE is to have a time stamp prior to TRIGGER, but this isn't what we wanted. We want PRIOR update)

    'Table' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
    ---- ----------------- -------------------------------
    T1   U                 13-OCT-15 03.07.01.775236 AM   <<---------- This is the main table, This should have the latest timestamp
    T2   I                 13-OCT-15 03.07.01.775953 AM
    

    Here is my test case.

    DELETE FROM TEST_TRIGGER_1;
    
    DELETE FROM TEST_TRIGGER_2;
    
    SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
    UNION
    SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;
    
    INSERT INTO TEST_TRIGGER_1 (ID,ibm_snapoperation, ibm_snaplogmarker)
         VALUES (1, 'I', SYSTIMESTAMP);
    
    COMMIT;
    
    SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
    UNION
    SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;
    
    UPDATE TEST_TRIGGER_1
       SET IBM_SNAPOPERATION = 'U', ibm_snaplogmarker = SYSTIMESTAMP;
    
    COMMIT;
    
    SELECT 'T1', ibm_snapoperation, ibm_snaplogmarker FROM TEST_TRIGGER_1
    UNION
    SELECT 'T2', ibm_snapoperation, TRG_INS_TMST FROM TEST_TRIGGER_2;
    

    Def trigger:

    CREATE OR REPLACE TRIGGER etl_dbo.TEST_TRIGGER_1_TRG BEFORE UPDATE OF IBM_SNAPOPERATION
    ON TEST_TRIGGER_1 REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    WHEN (
    NEW.IBM_SNAPOPERATION= 'U'
          )
    DECLARE
    V_SQLCODE  VARCHAR2(3000);
    --PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    INSERT INTO etl_dbo.TEST_TRIGGER_2
    (ID,
    IBM_SNAPOPERATION,
    IBM_SNAPLOGMARKER,
    TRG_INS_TMST
    )
    VALUES (:OLD.ID,:OLD.IBM_SNAPOPERATION,:OLD.IBM_SNAPLOGMARKER,SYSTIMESTAMP)
    ;
    --COMMIT;
    END;
    /
    

    Output is something like this

    1 row deleted.
    1 row deleted.
    no rows selected.
    1 row created.
    Commit complete.
    
    'T1' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
    ---- ----------------- -------------------------------
    T1   I                 13-OCT-15 03.07.00.927546 AM 
    1 row selected.
    1 row updated.
    Commit complete.
    
    'T1' IBM_SNAPOPERATION IBM_SNAPLOGMARKER            
    ---- ----------------- -------------------------------
    T1   U                 13-OCT-15 03.07.01.775236 AM   <<---------- This is the main table, This should have the latest timestamp
    T2   I                 13-OCT-15 03.07.01.775953 AM 
    
    2 rows selected.
    

    But for some reason, even after the creation of the 'AFTER' trigger for update, it works as expected. Sense - the main table is not having the last timestamp given

    It's OKAY - I told you in my reply earlier. Reread my answer.

    could understand somehow that the UPDATE statement is made with earlier

    SYSTIMESTAMP until the TRIGGER is assessed and updated so is to have

    time stamp prior to the trigger, but this isn't what we wanted. We want to

    BEFORE the update)

    As I told you before that your UPDATE statement occurs BEFORE the trigger is activated.

    Despite what the other speakers have said, it makes NO DIFFERENCE if you use a BEFORE UPDATE or an AFTER UPDATE trigger. Your UPDATE statement runs ALWAYS BEFORE the trigger.

    HE has TO - it's your update processing statement that causes the trigger to fire.

    Your update statement includes SYSTIMESTAMP. If during the processing of your return to update the value of SYSTIMESTAMP "at this exact time" is captured.

    Then your trigger is activated and starts to run. ANY reference to SYSTIMESTAMP that you use in your trigger cannot be earlier than the value of until the trigger was executed. It's IMPOSSIBLE.

    The trigger can use the SAME value by referencing: NEW and the column name you store the value. Or the trigger can get its own value that your code is doing.

    But the SYSTIMESTAMP value in the trigger will NEVER earlier than the value in your query.

    And none of these values can actually be used to tell when the changes are really ENGAGED since the trigger does not work and CAN NOT, to know when, or if, a validation occurs.

    Reread my first answer - he explains all this.

  • Problem with cursor and Transactions

    Hi friends,

    I will carry out the sub set of orders where some records are removed as a transaction. If there is no problem with a set of transactions, this recordset is ignored and following Recordset is executed. With code below, if an error occurs in one of the statement, control passes to the exception block where it cancels the registration point and unwanted instructions are restored. So far so good. But the problem is execution stops here. I need to skip this record id and loop for remaining IDs. Help, please.


    create or replace PROCEDURE DeleteRecords
    AS
    SelectDate date: = SysDate () - 27;
    NRTSI varchar2 (100);
    CURSOR c_TrnInfoNull IS select id from trn_info where CREATED_TISTMP < SelectDate and trn_tistmp is set to null;
    BEGIN

    FOR myrows IN c_TrnInfoNull LOOP
    SAVEPOINT TrnSavePointNull;
    delete from TRN_ERROR_DETAIL where TRN_INFO_ID = myrows.id;
    Select code from NRTSI from TRN_PYMT_DETAIL where trn_info_id = myrows.id;
    delete from TRN_PYMT_ADDNL_DATA where TRN_PYMT_DETAIL_ID = NRTSI;
    delete from TRN_PYMT_DETAIL where ID = NRTSI;
    delete from trn_info where id = myrows.id;
    COMMIT;
    END LOOP;

    EXCEPTION, THEN, THEN go BACK to TrnSavePointNull.
    DBMS_OUTPUT. Put_line (dbms_utility. FORMAT_ERROR_BACKTRACE());
    END;
    create or replace PROCEDURE DeleteRecords
    AS
    SelectDate date:= SysDate()-27;
    TRNID varchar2(100);
    CURSOR c_TrnInfoNull IS select id from trn_info where CREATED_TISTMP
    
  • Add box of relaxation with the text?

    When I add a relaxation area, I would like that he looks just like the three that appear by default. But add those I have no text to the breast area. Is it possible to add a trigger/text/box similar to the three that appear automatically?

    Hi Kimberly,

    When adding a new target with a rectangle, a new trigger is created. You can then add a text box or a picture in the rectangle.

    Kind regards

    Aish

  • With the DDL transaction number

    Is it true you will get the error trying to execute DDL for some a table if there is an active transaction at this table? Take a look at this case:
    insert into t1 values(1,2,3)
    drop table t1
    as you can see, I don't have "commited yet, if the T1 transaction is still active.

    I tried to open a new session in SQL Developer just to confirm that the DML insert has not been committed yet
    select * from t1
    and Yes, it returns no rows.

    I was expecting error, but the
    drop table t1
    did not produce an error. He successfully executed. Am I missing something? Thank you

    You need to do the INSERTION and the FALL in two different sessions to generate an error (ORA-00054: resource busy and acquire with NOWAIT specified).

    DDL performs an implicit validation before and after that the DDL is executed. If your DROP statement commits first INSERT then drops the table and finally delivers a further validation. That does not generate errors because by the time wherever the table is deleted, there is no active transaction. In addition, even if there is an active transaction, the you'll never erred waits for a lock that already has your session. Because locks are held by the session, various statements in the same session cannot block the other.

    Justin

  • JMS sender with container managed transaction ejb3

    Hi all

    I refer to the following link http://download.oracle.com/docs/cd/E11035_01/wls100/jms/trans.html#wp1035937

    I found that JTA support JMS.

    But I have no ' to use JTA explicitly, I want to use the container to manage the transaction. for example. within the ejb3 stateless session bean.

    support JMS?

    With respect,
    WP

    Hello

    Yes, WebLogic JMS supports JTA (alias XA, a.k.a global) transactions such as container managed transactions. There are two conditions for CMTs on SSB:

    (1) use a parameter descriptor XML or EJB annotation to turn on CMT for SSB

    (2) use a WebLogic JMS connection factory that is configured to have 'global transactions (XA) enabled.

    And I usually recommend also:

    (3) consider using a JEE 'res-ref' for the connection factory to allow reunification of the JMS resources. See "Enhanced Support for using WebLogic JMS with EJB and servlet ' (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/j2ee.htm#g1329180) and the 'integration JMS remote suppliers' FAQ (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/interop.htm#JMSPG553).

    (4) avoid using a BSN to receive messages. BMD is designed to process incoming messages.

    It is also possible to have WebLogic automatically registered foreign suppliers (non-WebLogic) in WebLogic transactions. See the 'integration JMS remote suppliers' FAQ for more details (http://download.oracle.com/docs/cd/E14571_01/web.1111/e13727/interop.htm#JMSPG553).

    Kind regards

    Tom

  • L2 roaming with 2 autonomous access points?

    Hello

    Is it possible for 2 1130AG in stand-alone mode to quick support layer 2 roaming?

    My clients are a mix of clients of compatible and not cisco cisco ccx.

    (Authentication could be open or WPA etc.)

    If so, do 1 AP do acts as a WDS?

    I fell on the docs that say I need a WLSM and that an acting as a WDS AP don't work...

    If I do not use WDS and simply have 2 AP with the same SSID: -.

    If I only use open authentication, then the roam would be a little faster?

    The AP would update switches upstream MAC tables when a customer changes AP?

    Thank you

    Oh, I see now. You get absolutely L2 roaming out of the box. It's all part of the 802.11 Protocol - the customer will inform current accreditation which he left, which AP it will and then he will wander. With open authentication or PSK, it will be almost transparent to the client.

    Cisco Secure fast roaming is an entirely different topic. In the above case, if the customer is using the PEAP Protocol, it will need to authenticate to the RADIUS server whenever he roams to a new AP. Cisco FSR puts cached credentials in the WDS AP for fast authentication, which takes the RADIUS server outside the process. This significantly speeds up a course for users of the EAP, and it is especially noticeable (and necessary) for wireless IP phone users.

    Again, I hope it helps!

  • Engage the creativity with the Cloud?

    I would like to know how to access the new range of Adobe applications. However, this is not prove easy and a "glich" seems to happen at all stages: being passed from one Department to the other.

    With a growing workload, it is essential that I am able to work faster. See the creative cloud, I thought to report without delay: this is the product for me!

    I'm looking for help to install PhotoShop CS6 currently a subscription cloud creative member. £46:88 per month. Order No. AD001224841UK. Order date: 30 October 2012.

    Is there any help Adobe out there please?

    You had not verified, your Adobe ID email address. You should have received an email providing a link to do this. I forced a verification of your email and so you should now be able to connect to the cloud of Creative.

  • error with triggers

    Hi all
    I get the error message with trigger
    What is the meaning of the error message
    and how to fix it?
    Error at startup on line 63 of order:
    call xx_GL_Vacancies.delete_transaction (128540)
    Error report:
    SQL Error: ORA-06519: active transaction autonomous detected and restored
    ORA-06512: at "XXGLOBALLOGIC. XX_GL_VACANCIES', line 37
    06519 00000 - "active autonomous transaction detected and restored.
    * Cause: Before returning from a PL/SQL stand-alone, autonomous everything block
    > transactions started in the block must be completed (either
    (> validated or cancelled). If not, activate autonomous
    > transaction implicitly rolls back and this error.
    * Action: make sure that before you return from an autonomous PL/SQL block,
    > autonomous all active transactions are explicitly engaged
    or restored back.

    I'm not angry.
    "You wouldn't like me when I'm angry."
    http://en.Wikipedia.org/wiki/The_Incredible_Hulk _ (TV_series)

    Just keen you can do good things.

    Think about what's going on with this autonomous transaction.
    If I run a delete transaction that subsequently cancels for any reason, you have just updated your xx_per_all_vacancies table.
    And you did it in a standalone transaction.
    That must be validated.
    So it won't restore.
    Is that what you want?

    Unless you connect to something that should engage regardless of the success or failure of the main operation, you should not use autonomous transactions.

    None of the actions performed by your trigger must be commit the code to be directly in a trigger or procedure.

    You should also read up on statement restarts and the consequences for triggers to see why the use of the autonomous transaction is doubly bad.
    http://tkyte.blogspot.com/2010/04/that-old-restart-problem-again.html

    So, in summary, if you really need to do all this in a trigger (really?) have then the logic of the trigger or call to a procedure (preferable), do not use an autonomous transaction, not to commit. Simple.

    Also, if it doesn't "work" provide a bit more detail. Error messages, line numbers, they are all here to help. To say something is does not, is not useful.

    Published by: Dom Brooks on February 23, 2011 11:23

    Published by: Dom Brooks on February 23, 2011 11:26

  • How to create and insert data with Execute Immediate?

    Hi guys

    Am stuck on a procedure of formatting in a package... script works okay however integrating a module turns out to be difficult!

    Am not used to oracle... I have the script runs, but not in the package... Well not all that... Drop Table worked

    CREATE or REPLACE PACKAGE BODY is

    PROCEDURE DropTable1 IS

    BEGIN

    run immediately ("DROP TABLE mytable1");

    END;

    PROCEDURE PopulateTable1 IS

    BEGIN

    immediately execute ('CREATE TABLE mytable1 )

    AS LONG AS)

    Select

    substr (T1.genarea, 3, 3) as M_Class,

    substr (T1.genarea, 6, 30) as M_Description,

    substr (T1.genarea, 36, 3) as M_Class,

    substr (T1.genarea, 39, 30) as M_Description,

    substr (T1. ItemItem, 1, 3) as product_code,.

    T3. CHANNEL_NUM as SALES_CHANNEL,

    to_date(''t2.time_id'',''dd-mon-yyyy'') as mis_date,

    Sum (T2.ap_cw_cfi_irp + T2.ap_cw_issues_irp) as ap_gross,

    sum (t2. Ap_Cw_Cfi_Irp + t2. Ap_Revivals_Irp) as ap_net,

    Sum (T2.sp_inc_irp + T2.sp_issues_irp) as sp_gross,

    Sum (T2.sp_dec_irp + T2.sp_fs_irp) as sp_net

    Of

    d_pr t1, t2 age_map t3 law

    where

    T1.pfx = "WE"and t1.coy ="1" and t1.tabl = "T81" and substr (t1.itemitem, 1, 3) = t2.product_id and t3. AGE_NUM = t2.age_id

    Group

    substr (T1.genarea, 3, 3),

    substr (T1.genarea, 6, 30),

    substr (T1.genarea, 36, 3),

    substr (T1.genarea, 39, 30),

    substr (T1. ItemItem, 1, 3).

    T3. CHANNEL_NUM,

    to_date(''t2.time_id'',''dd-mon-yyyy'')

    )');

    COMMIT;

    END PopulateTable1;

    END test;

    /

    Thank you

    Hello

    a few notes.

    1. to_date(t2.time_id,'dd-mon-yyyy')

    New York T2.Time_ID Cis the varchar2 data type that contains values to JJ-me-YYYY format?

    And if, in which language is used for the names of the months? Conversions are point impossible to solve in reasonable time limits without logging of dml errors and unique failure on charges of staging nightly!


    2 single quote escaping "alternative in string literals.

    You can use Q or q to escape single quotes in strings.

    http://docs.Oracle.com/database/121/SQLRF/sql_elements003.htm#SQLRF00218

    3. validation

    Not required because the DDL commands commit implied.

    In general I recommend you write commit clauses only in calling script rather than in the code unless it connects with an autonomous transaction.

    You end up with a lot of validation of code here and there and you don't know where it is and where it isn't. That is, your process may have more than one appeal process and commit the middle of the process, it is not atomic processes.

    Here's the demo although I recommend also using the static table and truncate to efficiency. ETG is good choice for the purpose of maintenance table.

    create or replace
    package testing is
      procedure staging_one;
    end;
    /
    create or replace
    package body testing is
      --
      procedure staging_one is
        --
        procedure drop_staging_one is
          table_does_not_exist exception;
          pragma exception_init(table_does_not_exist, -00942);
        begin
          execute immediate q'{
            drop table staging_one purge
          }';
        exception when table_does_not_exist then
          return; -- fine
        end;
        --
        procedure create_staging_one is
        begin
          execute immediate q'{
    
            -- remove >>>
            create table staging_one nologging
            as
            select * from dual
            -- <<< remove
    
            /* uncomment >>>
            create table staging_one nologging
            as
            select
              substr(t1.genarea,3,3)                    as m_class,
              substr(t1.genarea,6,30)                   as m_description,
              substr(t1.genarea,36,3)                   as m_class,
              substr(t1.genarea,39,30)                  as m_description,
              substr(t1.itemitem,1,3)                   as product_code,
              t3.channel_num                            as sales_channel,
              to_date(t2.time_id,'dd-mon-yyyy')         as mis_date,
              sum(t2.ap_cw_cfi_irp+t2.ap_cw_issues_irp) as ap_gross,
              sum(t2.ap_cw_cfi_irp+t2.ap_revivals_irp)  as ap_net,
              sum(t2.sp_inc_irp   +t2.sp_issues_irp)    as sp_gross,
              sum(t2.sp_dec_irp   +t2.sp_fs_irp)        as sp_net
            from
              d_pr t1,
              act t2,
              age_map t3
            where
              t1.pfx                      = 'IT'
              and t1.coy                  = '1'
              and t1.tabl                 = 'T81'
              and substr(t1.itemitem,1,3) = t2.product_id
              and t3.age_num              = t2.age_id
            group by
              substr(t1.genarea,3,3),
              substr(t1.genarea,6,30),
              substr(t1.genarea,36,3),
              substr(t1.genarea,39,30),
              substr(t1.itemitem,1,3),
              t3.channel_num,
              to_date(t2.time_id,'dd-mon-yyyy')
            <<< uncomment */
          }';
          --
        end;
      -- main
      begin
        drop_staging_one;
        create_staging_one;
      end;
    end;
    /
    
    set serveroutput on
    
    exec testing.staging_one;
    
    select * from staging_one
    ;
    commit
    ;
    
    PACKAGE TESTING compiled
    PACKAGE BODY TESTING compiled
    anonymous block completed
    DUMMY
    -----
    X 
    
    committed.
    

Maybe you are looking for

  • How to disable the Touchpad in windows XP...

    so, anyone know how to disable the touchpad mouse in notebook Lenovo G410? Is there software available for this? I use windows xp. I downloaded ALPS touchpad drivers and support from lenovo, but I does not work there is no functionality in the softwa

  • Need driver Vista for Bluetooth dongle model: TechBlue1

    Hello I recently had a Technika Bluetooth dongle, model: TechBlue1 and it is not supported by Vista. Are there updates or drivers that will allow for this?

  • 4810 error to its reading file Open.vi

    Hello I'm getting a '4810 error to file read Open.vi' for the attached wav file (much to other wav files). Any ideas? Thank you Rob

  • Do you know what is PerformerSoft LLC?

    This is a file it is whenever I turn on my computer to the top pop. I don't know what it is and I can not find PerformerSoft LLC in my install or uninstall on my computer. My computer says it can damage or damage to my computer, and I don't know how

  • How can I fix WinMail error code 0 x 80070002, MSOE.dll could not be initialized?

    Suddenly, I was unable to access my aol e-mail account via winmail as I did for some time.  I get an error message that says: "Windows Mail could not be started.  initialize junk filtering.  Your computer may be out of memory or your disk is full. (0