ORA-04092

Hi All,
I have created row level insert trigger t1 which based on some conditions call Procedure P1.
If Procedure P1 succeeds then it calls Procedure P2...P12.
In Procedure P12 i am issuing a commit statement.
Now when i insert a new row into the table the procedure is called and everything works as required.
But when the procedure P12 issues the commit statemtent the error message ORA-04092: cannot COMMIT in a trigger
is encountered. I was under the impression that we cannot commit inside a trigger but can
do through a procedure.
Please give your comments.
Thanks.

The solution is simple. You cant issue a commit inside a trigger even if the commit is embedded in a procedure. That does not make any sense. Remove the commit from p12 and put it after the insert statement that invokes the trigger.
You don't want your data to get committed if the insert fails correct?

Similar Messages

  • SQL Error: ORA-04092: cannot COMMIT in a trigger

    Trying to drop the table inside the trigger but i'm unable to do it.
    SQL Error: ORA-04092: cannot COMMIT in a trigger
    I need to drop the table based on the some condition say condition is the archive table with more than millions of records which is of no use so i plan to drop the table.
    I will be inserting the the unwanted table to mytable ,mytable which is having the trigger will fire to drop the table.
    I need this to be done on automatic basis so i have chosen trigger.
    is there anyway of automatic other than trigger in this case.

    933663 wrote:
    Trying to drop the table inside the trigger but i'm unable to do it.
    SQL Error: ORA-04092: cannot COMMIT in a trigger
    I need to drop the table based on the some condition say condition is the archive table with more than millions of records which is of no use so i plan to drop the table.
    I will be inserting the the unwanted table to mytable ,mytable which is having the trigger will fire to drop the table.
    I need this to be done on automatic basis so i have chosen trigger.
    is there anyway of automatic other than trigger in this case.You can't COMMIT inside a trigger. Oracle issue an auto COMMIT before and after the execution of DDL. So you can't use DDL in trigger. You may get suggestion to use AUTONOMOUS_TRANSACTION to perform COMMIT within tirgger. But dont do that. Its wrong idea.
    I will suggest you look back into your requirement and see what exactly you want. You could schedule a job that runs on a daily basis that will pick up the object details from your table and drop them accordingly.

  • Wf_event.raise : database trigger : ORA-04092 : differs from documented behavior

    Product Management :
    Calling wf_event.raise from an after insert row trigger produces ORA-04092. This is exactly opposite from the supposed documented behavior.
    Thanks in advance for your attention to this matter. Needless to say, raising business events from fundamental database activities like inserting & updating rows is critically important.
    Version : 2.6.2 as distributed with 9iAS 9.0.2.0.1 on Win2K
    Error message :
    ORA-04092: cannot ROLLBACK in a trigger
    ORA-06512: at "OWF_MGR.WF_EVENT", line 830
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-06512: at "OWF_MGR.WF_EVENT", line 451
    ORA-06512: at "CASEINT.CG$AIR_FOLDERS", line 7
    ORA-04088: error during execution of trigger 'CASEINT.CG$AIR_FOLDERS'
    From the Oracle Workflow Guide :
    "For environments such as database triggers or distributed
    transactions that do not allow savepoints, the Workflow Engine
    automatically traps Savepoint not allowed errors and defers
    the execution of the activity to the background engine."

    The Business Event System and Workflow Engine are two different components, hence the documentation is actually
    correct as it refers to the 'Workflow Engine' specifically.
    A fix is currently being developed for the problem that you are encountering and will be included in Workflow Standalone
    Version 2.6.3 (iAS 9.0.4).
    There is also a Bug raised for this issue in Workflow 2.6.2 - Bug 2427354 - if you wish to escalate this then please contact
    Oracle Support to raise a TAR against this Bug.
    As a workaround in the meantime you could launch a deferred workflow process that raises the required event.

  • Ora-04092 and PL/SQL

    Hi,
    I've a table and an attached trigger calling a PL/SQL procedure.
    The procedure creates a table, a trigger on that table and some VPD policies using the EXECUTE IMMEDIATE function.
    Each time I enter a new row in the table I get the ORA-04092 error.
    I've check all my codes and there is no commit writen somewhere. I strongly suspect that the EXECUTE IMMEDIATE is the problem.
    How can I bypass the problem?
    Cheers,
    Sebastien

    you need another way to implement this.
    A trigger fires when you do DML on a table (dependent on the type of trigger), not at COMMIT-time.
    What about this scenario:
    1) users adds record to table
    2) causing the trigger to fire
    3) table, trigger and VPD are created
    4) user rollback the action
    result: a table, trigger and VPD without a record in the table. And I assume this is not what you want.
    What you could do, is create a job which creates the table, trigger and VPD. Submit the job from the trigger.
    Jobs will only run when the user commits, when the user rolls back the transaction, the job automatically rolls back as well.
    Here is a blog on "transaction dependent webservice invocation", the basic idea is as I described above.
    http://technology.amis.nl/blog/1604/transaction-dependent-webservice-invocationor-how-to-call-a-webservice-from-a-database-trigger-and-make-the-call-part-of-the-transaction

  • ORA-04092 trying to analyze table

    Hi,
    I was trying to analyze some tables issuing:
    analyze table owner.table_name compute statistics;
    Immediately raises the ora-04092, as far as I seen, read, and googled, this ORA error occurs only when someone try to commit inside a trigger, but clearly this is not the case.
    And even in some web applications this error appears.
    This error started to occur after session limit exceeded, doesn't sound related to me, but maybe it can be interesting information.
    Any suggestions please, I'm comfused.
    Regards

    Here more information:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SO: RHELAS 5
    And according recomendation, I tryed to use DBMS_STAT, with same results:
    SQL> conn system/*******@siin
    Connected.
    SQL> conn mailedu/*******@siin
    ERROR:
    ORA-04092: cannot COMMIT in a trigger
    ERROR:
    ORA-24315: illegal attribute type
    Warning: You are no longer connected to ORACLE.
    SQL> conn mailedu/********@siin
    ERROR:
    ORA-24315: illegal attribute type
    SQL> conn system/********@siin
    ERROR:
    ORA-24315: illegal attribute type
    Once I restart sqlplusw, and I could connect (just the first connect is successfull) I tryed with dbms_stats:
    SQL> exec dbms_stats.gather_schema_stats ( -
    ownname => 'MAILEDU', -
    options => 'GATHER' );BEGIN dbms_stats.gather_schema_stats ( ownname => 'MAILEDU', options => 'GATHER' ); END;
    ERROR at line 1:
    ORA-04092: cannot COMMIT in a trigger
    ORA-06512: at "SYS.DBMS_STATS", line 14002
    ORA-06512: at "SYS.DBMS_STATS", line 13974
    ORA-06512: at line 1
    Looking further inside the forum I found this thread:
    stupid ora-04092 error message
    In the conversation it is mentioned that according document Link:[7886990|https://metalink.oracle.com/CSP/ui/flash.html#tab=KBHome(page=KBHome&id=()),(page=KBNavigator&id=(bmDocDsrc=Bug&bmDocTitle=AFTER%20OCCURRING%20ORA-18,%20ORACLE%20THROWS%20ORA-4092%20CONTINOUSLY&bmDocID=7886990&viewingMode=1143&from=BOOKMARK&bmDocType=BUG))]
    it can occur after ORA-00018 maximum number of sessions exceeded
    this one is my scenario,
    And...
    Bug No: 6977167
    Filed 16-APR-2008 Updated 19-AUG-2009
    Product Oracle Server - Enterprise Edition Product Version 10.2.0.2
    Platform Linux x86-64 Platform Version rel4
    Database Version 10.2.0.2 Affects Platforms Generic
    Severity Severe Loss of Service Status Development to Q/A
    Base Bug N/A Fixed in Product Version 11.2
    So I would like to mark this as a known bug, but I don't know how to proeced.
    Regards

  • ORA-04092: cannot COMMIT in a trigger - Please advise on solution

    Hi guys,
    I know this error has been explained in the forum before and I understand where the error comes from, but I need expert's opinion to make the trigger works.
    Here is the actual situation:
    Table A has a trigger on after insert, and BASED ON THE LAST ROW inserted (only this data is subject to the trigger's actions) does the following:
    1. MERGE the data (last row from the source table=A) with the data from the table destination=B. This data is specific to an employee;
    2. Open a cursor that goes through all the ancestors of the employee (I have an employees hierarchy) and MERGE the same data (but for ancestors) with the table destination;
    To be more specific :
    EmpID LOB Day Status
    12 1007 29 Solved
    EmpID has ancestors 24 and 95. Therefore in the destination table I will have to do:
    1. Merge data for EmpID 12;
    2. Merge data for EmpID 24, 95:
    EmpID LOB Day Status
    24 1007 29 Just S (this is the status for ancestors)
    95 1007 29 Just S
    Steps 1 and 2 are inside a PL/SQL procedure that works fine by itself, but not within the trigger (since there are many transactions on the destination table). These 2 steps are required because for EmpID 12 I set a status and for the ancestors I set up a different status (this was the only way I could think of).
    Can someone give me a hint how should I handle this situation ?
    Thank you,
    John

    Try this
    create or replace procedure SEQ
    is
    pragma AUTONOMOUS_TRANSACTION;
    BEGIN
    EXECUTE IMMEDIATE 'create sequence ' || V_PROD ||
    ' minvalue 1 maxvalue 999999 start with 1';
    END;
    CREATE OR REPLACE TRIGGER TRG_GEN_SEQUENCES
    BEFORE INSERT on MASTER_TABLE
    FOR EACH ROW
    DECLARE
    V_PROD VARCHAR2(5);
    N_ID NUMBER := 0;
    CT NUMBER := 0;
    ERR_MSG VARCHAR2(2000);
    BEGIN
    -- Retrieve the ID e of the last inserted row which is 100 by default
    -- set the default client_id value with nextvalue of sequence prod_IDS
    IF :NEW.ID = 100 THEN
    V_PROD := :NEW.PROD;
    SELECT PROD_IDS.NEXTVAL INTO N_ID FROM DUAL;
    :NEW.ID := N_ID;
    END IF;
    BEGIN
    SELECT COUNT(*)
    INTO CT
    FROM USER_SEQUENCES US
    WHERE UPPER(US.SEQUENCE_NAME) = UPPER(V_PROD);
    IF CT = 0 THEN
    -- create the sequence with name of V_PROD if doesn't exist
    INSERT INTO CDR_SQL_ERR
    (DB_OBJ, ERR_MSG, PROC_DATE)
    VALUES
    ('TRG_GEN_SEQUENCES',
    V_PROD || ' sequence will be created ', SYSDATE);
    --EXECUTE IMMEDIATE 'create sequence ' || V_PROD ||
    ---' minvalue 1 maxvalue 999999 start with 1';
    begin
    SEQ;
    end;
    ELSE
    INSERT INTO CDR_SQL_ERR
    (DB_OBJ, ERR_MSG, PROC_DATE)
    VALUES
    ('TRG_GEN_SEQUENCES',
    V_PROD || ' sequence alreday exist',
    SYSDATE);
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    ERR_MSG := TO_CHAR(SQLERRM) || ' ';
    INSERT INTO SQL_ERR
    (DB_OBJ, ERR_MSG, PROC_DATE)
    VALUES
    ('TRG_GEN_SEQUENCES', ERR_MSG || SEQ_DDL, SYSDATE);
    END;
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    ERR_MSG := TO_CHAR(SQLERRM) || ' ';
    INSERT INTO SQL_ERR
    (DB_OBJ, ERR_MSG, PROC_DATE)
    VALUES
    ('TRG_GEN_SEQUENCES', ERR_MSG || SEQ_DDL, SYSDATE);
    COMMIT;
    END;

  • ORA-04091: table is mutating, trigger/function may no

    Hi all,
    I'm trying to create a trigger, but I got the following:
    ERROR at line 1:
    ORA-04092: cannot ROLLBACK in a trigger
    ORA-06512: at "PKG_PROJ", line 63
    ORA-04091: table TBL_DATA is mutating, trigger/function may not see it
    ORA-06512: at "T$D_INS_TDATA", line 4
    ORA-04088: error during execution of trigger 'T$D_INS_TDATA'My trigger is:
    CREATE OR REPLACE TRIGGER T$D_INS_TDATA
           AFTER INSERT ON TBL_DATA
           FOR EACH ROW
    DECLARE
    BEGIN
         PKG_PROJ.P$INSERT(:NEW.ID);
         COMMIT;
    END;
    /Where meu procedure is:
           PROCEDURE P$INSERT
               P_ID      IN TBL_DATA.ID%TYPE
           AS
           BEGIN
                INSERT INTO TBL_DETAIL
                    ID_DETAIL,           DT_DETAIL, OBS,
                SELECT SEQ_DETAIL.NEXTVAL, SYSDATE, 'INSERT TRIGGER TEST'
                FROM TBL_DATA DC
                AND   DC.ID    =  P_ID
                COMMIT WORK;
            EXCEPTION
                     WHEN OTHERS THEN
                         ROLLBACK;
                         RAISE_APPLICATION_ERROR(-20102, 'PKG_PROJ.P$INSERT: ' || SQLERRM);
           END P$INSERT;Somebody can help me???
    thanx!!!! :-)

    Tad,
    I believe you're performing SELECT on the triggering table in the PL/SQL block. In simple words, you're trying to change the information of a table the TRIGGER is created for and you're trying to read data from the same table.
    I suggest that you use PL/SQL pragma autonomous_transaction to resolve this, for as per Oracle documentation "The AUTONOMOUS_TRANSACTION pragma instructs the PL/SQL compiler to mark a routine as autonomous (independent). An autonomous transaction is an independent transaction started by another transaction, the main transaction. Autonomous transactions let you suspend the main transaction, do SQL operations, commit or roll back those operations, then resume the main transaction."
    Furthermore, you can also refer to the following discussion by Thomas Kyte for further understanding of mutating tables:
    Avoiding Mutating Tables
    http://asktom.oracle.com/tkyte/Mutate/
    Hope this helps.
    Regards,
    Naveed.

  • Error creating job into trigger using DBMS_SCHEDULER.

    Hi,
    I am trying to create job using dbms_scheduler package. I have one trigger on insert event on one table. I am creating job using following syntax.
    CREATE OR REPLACE TRIGGER TRG_BI_JOB_CONFIG BEFORE INSERT ON JOB_CONFIG FOR EACH ROW
    DECLARE
    BEGIN
         DBMS_SCHEDULER.Create_Job(job_name => 'my_job1'
                             ,job_type => 'PLSQL_BLOCK'
                             ,job_action => 'delete_temp'
                             ,start_date => TO_DATE('15-JUL-2003 1:00:00 AM', 'dd-mon-yyyy hh:mi:ss PM')
                                  ,repeat_interval => 'FREQ=DAILY'
                             ,enabled => TRUE
                             ,comments => 'DELETE FOR job schedule.');
    EXCEPTION
    WHEN OTHERS THEN RAISE;
    END;
    but I am getting following error while inserting into JOB_CONFIG table.
    ORA-04092: cannot in a trigger
    ORA-06512: at "PRAKASH1.TRG_BI_JOB_CONFIG", line 41
    ORA-04088: error during execution of trigger
    same above statement If I am running from sqlplus then It is creating job without error. If I am creating job using DBMS_JOB into trigger then It is also working fine but this package is depricated from oracle10g so I cannt use it any more.
    My Oracle version is 'Oracle DATABASE 10g RELEASE 10.2.0.1.0 - Production'.
    can anyone help me in this context.

    I have a few comments on this thread as an Oracle dbms_scheduler developer.
    - Oracle takes backward compatibility very seriously. Although dbms_job is deprecated, the interface will continue to work indefinitely. The deprecation of dbms_job is so that customers will be encouraged to take advantage of the more powerful dbms_scheduler. It is extremely unlikely that entire blocks of functionality will ever be removed. There is currently no plan to remove dbms_job functionality (and even if there were, doing so would be strenuously opposed by many users).
    - lots of internal Oracle database components are standardizing on using dbms_scheduler (resource manager, materialized views, auto sql tuning etc). This is good evidence that it will continue to be the recommended scheduling method for the foreseeable future - not even the concept of a replacement exists. It is also under active development.
    - The reason for the automatic commit is that a dbms_scheduler job is a full database object like a stored procedure or a table. So a call to dbms_scheduler.create_job is like executing a DDL which takes effect immediately. A dbms_job job is mostly just a row in a table so a call to dbms_job.submit behaves like regular DML. There are many advantages to a job being a full database object but DDL behaviour is an unfortunate requirement of this.
    Hope this clears a few things up, reply with any questions.
    -Ravi

  • Getting the error "Error while trying to update record" when I try to force complete a plan in DAC

    Hello Everyone ,
    I am using OBIA 7.9.3.7 . One of my execution plan has finished executing all the tasks but it is still in running mode . When I try to force complete it , it gives the error " Error while trying to update record" . Upon checking the log file , I found the below errors :
    MESSAGE:::ORA-04092: cannot COMMIT in a trigger
    ORA-06512: at "DAC_CUSTSCM.ETL_FAIL_NOTOFICATION", line 9
    ORA-04088: error during execution of trigger 'DAC_CUSTSCM.ETL_FAIL_NOTOFICATION'
    EXCEPTION CLASS::: java.sql.SQLSyntaxErrorException
    The Plan is in running state for past couple of days . I tried to re-start the DAC services , but again it gave the same error . Kindly suggest .
    Regards
    Satyendra

    Just to correct , the version of obia is 7.9.6.3

  • How to run DDL in a Trigger?

    I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.
    . The problem is, I am getting an ERROR at line 1:
    ORA-04092: cannot COMMIT in a trigger
    CREATE OR REPLACE TRIGGER TESTER.AUTO_QUOTA
    AFTER INSERT ON USERS FOR EACH ROW
    DECLARE
    sqlstmt     VARCHAR2(100);
    BEGIN
    sqlstmt:='ALTER USER ' || :NEW.USERNAME || ' QUOTA UNLIMITED ON ' || :NEW.TABLESPACE_NAME;
    execute IMMEDIATE SQLSTMT;
    END;
    /

    ji**** wrote:
    I am trying to create a trigger that automatically sets the quota for any new users created in the database. However, I am running into the follow error because whenever you run DDL, Oracle automatically commits, which you can't do in a trigger. Does anyone have any ideas on how to get around this? We are on Oracle 11gR1.This approach is wrong.
    What is the purpose of a trigger? The answer is protecting the integrity of the transaction - not to do "extra stuff" outside the current actual business transaction. Like sending e-mails. Or SMS's. Or issue DDL commands.
    What happens when you do "extra stuff" in that trigger and the transaction is rolled back for example? What now happens to that "extra stuff" that should not have existed/have been done in the first place?
    The correct approach is to create a procedure or package that does this "extra stuff". Then schedule a job from this trigger to call that procedure.
    When the transaction commits, so too is the job to do the "extra stuff". If the trigger is rolled back, so too the submission of the job. And the trigger does not need smelly approaches like autonomous transactions for getting "extra stuff" done.

  • Trigger and rollback on oracle 9i

    hi,
    i work on oracle 9i.
    in my database i import csv file in en temporary table and make a trigger to update 2 table after insert.
    i want to make a csv file wich contain each not good row.
    i search a way to cancel the first update if the second update is not good
    i try to use a autonomous transaction but there is an error...maybe you can help me and give me a solution to my probleme.
    my trigger's code
    declare
    gache NUMBER;lieu NUMBER;reference NUMBER;test UTL_FILE.FILE_TYPE; erreur NUMBER;
    v_file UTL_FILE.FILE_TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
    commit;
    SELECT id_lieu INTO lieu
    FROM TBL_LIEU
    WHERE est_xgs_lieu=1;
    IF :NEW.dateImpr IS NOT NULL THEN
    IF :NEW.preImpcode1 IS NOT NULL AND :NEW.preImpQt1>0 THEN
    SELECT id_reference,POURCENTAGE_GACHE_REFERENCE INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode1
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
    INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
    VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt1*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt1*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
         END IF;
    IF :NEW.preImpcode2 IS NOT NULL AND :NEW.preImpQt2>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode2
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt2*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt2*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
         END IF;
    IF :NEW.preImpcode3 IS NOT NULL AND :NEW.preImpQt3>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode3
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt3*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt3*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    END IF;
    IF :NEW.preImpcode4 IS NOT NULL AND :NEW.preImpQt4>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode4
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp,ROUND(:NEW.preImpQt4*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt4*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    END IF;
    IF :NEW.preImpcode5 IS NOT NULL AND :NEW.preImpQt5>0 THEN
    SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.preImpcode5
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt5*((gache/100)+1)), 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt5*((gache/100)+1))
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF reference IS NULL THEN
         erreur:=1;
         end if;
    END IF;
    END IF;
    IF :NEW.dateMsp IS NOT NULL THEN
    IF :NEW.encartCode1 IS NOT NULL AND :NEW.encartQt1>0 THEN
         SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode1;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp,:NEW.encartQt1,'Impression',lieu,reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt1
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.encartCode2 IS NOT NULL AND :NEW.encartQt2>0 THEN
    SELECT id_reference, pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode2;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
         VALUES(:NEW.dateExp, :NEW.encartQt2, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt2
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.encartCode3 IS NOT NULL AND :NEW.encartQt3>0 THEN
         SELECT id_reference , pourcentage_gache_reference INTO reference, gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode3;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp, :NEW.encartQt3, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt3
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF :NEW.encartCode4 IS NOT NULL AND :NEW.encartQt4>0 THEN
         SELECT id_reference , pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode4;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateExp,:NEW.encartQt4, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt4
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    IF :NEW.encartCode5 IS NOT NULL AND :NEW.encartQt5>0 THEN
         SELECT id_reference,pourcentage_gache_reference INTO reference,gache
    FROM TBL_REFERENCE
    WHERE code_reference_xgs=:NEW.encartCode5;
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
              VALUES(:NEW.dateExp,:NEW.encartQt5, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt5
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
         END IF;
    IF :NEW.codeEnv IS NOT NULL and :NEW.nbPlis>0 THEN
         SELECT id_reference INTO reference
    FROM TBL_REFERENCE,TBL_STOCK
    WHERE code_reference_xgs=:NEW.codeEnv
    AND id_reference=fk_reference
    and fk_lieu=lieu;
    IF reference IS NOT NULL THEN
         INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
         VALUES(:NEW.dateMsp, :NEW.nbPlis, 'Impression', lieu, reference);
         UPDATE TBL_STOCK
         SET nombre_volume_stock= nombre_volume_stock - :NEW.nbPlis
    WHERE fk_lieu=lieu
         AND fk_reference=reference;
    END IF;
    END IF;
    END IF;
    EXCEPTION
    when NO_DATA_FOUND then
    v_file:= UTL_FILE.FOPEN ('DOSSIER_EXP','rejet_stock'||to_char(sysdate,'DD-MM-YYYY-hh24-mi-ss')||'.csv','A',32767);
    UTL_FILE.PUT_LINE(v_file,:new.FLUXIDCLIENT||';'||:new.FLUXDATECREATION||';'||:new.NOMCLIENT||';'||:new.APPLILABEL||';'
    ||:new.LOTID||';'||:new.NUMEROBATCHSOUSLOT||';'||:new.FILIERE||';'||:new.DATEIMPR||';'||:new.DATEMSP||';'
    ||:new.DATEEXP||';'||:new.NBPAGES||';'||:new.NBPLIS||';'||:new.ISTEMPOST||';'||:new.SSLOTSTATUT||';'
    ||:new.NOMIMPRIMANTE||';'||:new.MODEIMPRESSION||';'||:new.ENCARTCODE1||';'||:new.ENCARTCODE2||';'||:new.ENCARTCODE3||';'
    ||:new.ENCARTCODE4||';'||:new.ENCARTCODE5||';'||:new.ENCARTQT1||';'||:new.ENCARTQT2||';'||:new.ENCARTQT3||';'
    ||:new.ENCARTQT4||';'||:new.ENCARTQT5||';'||:new.PREIMPCODE1||';'||:new.PREIMPCODE2||';'||:new.PREIMPCODE3||';'
    ||:new.PREIMPCODE4||';'||:new.PREIMPCODE5||';'||:new.PREIMPQT1||';'||:new.PREIMPQT2||';'||:new.PREIMPQT3||';'
    ||:new.PREIMPQT4||';'||:new.PREIMPQT5||';'||:new.CODEENV||';');
    UTL_FILE.FFLUSH (v_file);
    UTL_FILE.FCLOSE(v_file);
    erreur:=1;
    ROLLBACK;
    end;

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE)
    Sequence creation:
    CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE START WITH 6000 INCREMENT BY 1 MINVALUE 6000 MAXVALUE 6999 NOCACHE NOCYCLE NOORDER ;
    Trigger creation:
    CREATE OR REPLACE TRIGGER TEST_TABLE INSERT BEFORE INSERT ON TEST_TABLE FOR EACH ROW
    DECLARE
    pkValue NUMBER;
    BEGIN
    pkValue := 0;
    Select TEST_TABLE_SEQUENCE.NextVal into pkValue from dual;
    :NEW.TEST_KEY := pkValue;
    END TEST_TABLE_INSERT;
    We have created a snapshot of the schema on mobile server, synchronized the data with the client (Win32 for testing purpose).
    The trigger works fine on the server, but when I run the same query on the lite database with msql it gives me an error:
    [POL-3221] null key in primary index
    I was wondering if Sequence generation and Triggers are supported on Oracle 9i lite database ? Or am I missing out something ??
    Any information/ help is appreaciated
    Thanks
    Neeraj

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

  • Exception in Weblogic Server Starting

    Hi all,
    While starting weblogic server, I can see some exception as follows but server is started. Because of this I can't able to deploy OSM cartridges.
    java.sql.SQLSyntaxErrorException: ORA-04092: cannot COMMIT in a trigger
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.ja
    va:91)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:1
    33)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :206)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.
    java:191)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableSta
    tement.java:950)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
    nt.java:1223)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePrep
    aredStatement.java:3386)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    ement.java:3487)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStat
    ement.java:3858)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePrepa
    redStatementWrapper.java:1374)
    at oracle.jdbc.oracore.OracleTypeADT.initMetadata(OracleTypeADT.java:535
    at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java:462)
    at oracle.sql.ArrayDescriptor.initPickler(ArrayDescriptor.java:1678)
    at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:291)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:206)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:175)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:158)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:125)
    at oracle.jdbc.driver.NamedTypeAccessor.otypeFromName(NamedTypeAccessor.
    java:84)
    at oracle.jdbc.driver.TypeAccessor.initMetadata(TypeAccessor.java:89)
    at oracle.jdbc.driver.T4CCallableStatement.allocateAccessor(T4CCallableS
    tatement.java:629)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterIntern
    al(OracleCallableStatement.java:167)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Oracl
    eCallableStatement.java:208)
    at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParamete
    r(OracleCallableStatementWrapper.java:1584)
    at weblogic.jdbc.wrapper.CallableStatement_oracle_jdbc_driver_OracleCall
    ableStatementWrapper.registerOutParameter(Unknown Source)
    at com.mslv.oms.handler.util.j.prepareStatement(Unknown Source)
    at com.mslv.oms.dataaccesslayer.CallableProxy.prepareStatement(Unknown S
    ource)
    at com.mslv.oms.dataaccesslayer.a.execute(Unknown Source)
    at com.mslv.oms.dataaccesslayer.CallableProxy.execute(Unknown Source)
    at com.mslv.oms.handler.util.e.a(Unknown Source)
    at com.mslv.oms.eventengine.EventDispatcherEJB.processTimeout(Unknown So
    urce)
    at com.mslv.oms.eventengine.EventDispatcher_86q3j1_EOImpl.processTimeout
    (EventDispatcher_86q3j1_EOImpl.java:73)
    at com.mslv.oms.poller.a.handleNotification(Unknown Source)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor$ListenerWrapper
    .handleNotification(DefaultMBeanServerInterceptor.java:1732)
    at javax.management.NotificationBroadcasterSupport.handleNotification(No
    tificationBroadcasterSupport.java:257)
    at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(Noti
    ficationBroadcasterSupport.java:322)
    at javax.management.NotificationBroadcasterSupport$1.execute(Notificatio
    nBroadcasterSupport.java:307)
    at javax.management.NotificationBroadcasterSupport.sendNotification(Noti
    ficationBroadcasterSupport.java:229)
    at javax.management.timer.Timer.sendNotification(Timer.java:1237)
    at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1206)
    at javax.management.timer.TimerAlarmClock.run(Timer.java:1289)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
    <Nov 22, 2011 3:26:33 PM GMT+05:30> <Error> <oms> <BEA-000000> <util.e: Failed t
    o execute GetOrderTransitionProxy
    com.mslv.oms.dataaccesslayer.ProxyException: ORA-04092: cannot COMMIT in a trigg
    er
    Nested Exception: ORA-04092: cannot COMMIT in a trigger
    Can anybody pls help me to resolve this issue asap...
    Thanks in advance
    Bharathi

    Bharathi;
    The error indicates that a trigger is being executed. OSM DB schema does not make use of triggers at all. Has anyone added triggers to the OSM DB schema? If so this should not be done - modification or direct access of the OSM DB schema is not supported.
    Brian.

  • Proper use of htmldb_util.set_session_state

    Looking for a way to set a page variable from a trigger.
    I have an app that needs a variable set from within an insert trigger. I would like to let the user see the value of that variable on the page after the insert is complete.
    Can I use htmldb_util.set_session_state for that?
    Thanks.

    See
    Re: HTMLDB_TOOLS by Vikas need some helps about rollback(Urgent !!!)
    The problem is that htmldb_util.set_session_state does a COMMIT and as you know trigger code is not allowed to have a commit (ORA-04092: cannot COMMIT in a trigger)
    What you could try doing is create a little procedure as a autonomous transaction as a wrapper around htmldb_util.set_session_state
    create or replace procedure my_set_session_state
    p_item_name in varchar2,
    p_item_value in varchar2
    is
       PRAGMA AUTONOMOUS_TRANSACTION;
    begin
    htmldb_util.set_session_state(p_item_name,p_item_value);
    end;
    /and call that from your trigger.
    Hope this helps.

  • Getting all_tab_columns.data_default in a ddl trigger

    Under 10.1.0.3 I'm working on an AFTER CREATE or ALTER on DATABASE system trigger, and I'm querying all_tab_columns in the trigger body. It seems that if the trigger fires in response to DDL that modifies a column's default value, then all_tab_columns.data_default is giving me the column's old default. I want to get the current default value. If I create the table or add a column, then, in the resulting fire of the system trigger, all_tab_columns.data_default seems to be correct.
    Is this documented behavior? Should I be looking somewhere (or somewhen) else for the column default?

    Thanks.
    I tried working around this by putting my code into a procedure, and then using the DDL trigger to create a job that runs the code. My idea was to defer the all_tab_columns query until after the DDL trigger was done, and thus get a clean look at the data dictionary.
    I put what looks like the appropriate dbms_scheduler calls into the trigger, but when I then execute DDL to fire the trigger I get "ORA-04092: cannot in a trigger"
    The doc for this error number says that I am trying to commit or rollback in a trigger, but I'm not explicitly doing that. Also, the error message is supposed to have either the word "commit" or the word "rollback" in the message to tell me what I am doing. Instead, though, the error message just has a space there.
    Maybe I'll start a TAR and see if 10.1.0.3 can get appended to the growing list of versions tied to this bug.

Maybe you are looking for