Deferred Constraints - error on inserting

Hi there,
i've got a very courios problem with deferred constraints. My table creates are:
CREATE TABLE mitglied
( svnr NUMBER(10) NOT NULL,
  instr VARCHAR(20) NOT NULL,
  CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
CREATE TABLE abteilung
( instr VARCHAR(20) NOT NULL,
  geleitetVon NUMBER(10) NOT NULL,
  stvVon NUMBER(10) NOT NULL,
  CONSTRAINT abteilung_pk PRIMARY KEY (instr),
  CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
             REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
  CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
             REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
ALTER TABLE mitglied
  ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
                 REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;My Inserts (from sql-file):
INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune');
<all of the other "mitglied"-inserts>
INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
<all of the other "abteilung"-inserts>
COMMIT;The Error msg:
Error starting at line 79 in command:
INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune')
Error report:
SQL Error: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (U0426435.MITGLIED_FK) violated - parent key not found
(it's the same for all of the other mitglied-inserts), and of course, I get also errors on the abteilung-inserts.
I've already tried to solve this problem by using "SET AUTOCOMMIT OFF" in sqlplus, but that wasn't the point.
What's wrong with my Constraints?

Please post a complete example cut-n-paste from SQL*Plus window that shows the exact output step by step (as like below).
It apparently works for me as shown below.
SQL> CREATE TABLE mitglied
  2  ( svnr NUMBER(10) NOT NULL,
  3    mName VARCHAR(30) NOT NULL,
  4    gJahr INTEGER NOT NULL,
  5    aDat DATE NOT NULL,
  6    instr VARCHAR(20) NOT NULL,
  7    CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
Table created.
SQL> CREATE TABLE abteilung
  2  ( instr VARCHAR(20) NOT NULL,
  3    geleitetVon NUMBER(10) NOT NULL,
  4    stvVon NUMBER(10) NOT NULL,
  5    CONSTRAINT abteilung_pk PRIMARY KEY (instr),
  6    CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
  7               REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
  8    CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
  9               REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
Table created.
SQL> ALTER TABLE mitglied
  2    ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
  3                   REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;
Table altered.
SQL> INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', to_date('20-JAN-2005', 'dd-mon-yyyy'), 'Posaune');
1 row created.
SQL> INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
1 row created.
SQL> commit ;
commit
ERROR at line 1:
ORA-02091: transaction rolled back
ORA-02291: integrity constraint (OPS$LAPTOP\KKISHORE.ABTEILUNG_STVVON_FK)
violated - parent key not found
SQL>Message was edited by:
Kamal Kishore

Similar Messages

  • How can to see constraint error when inserting a dblink ?

    Hi
        When I Trying to insert in table in other server, using dblink  , return error dupl key, but I do not know what is key
    return me
    [pre]
    DUPL_CROTB_INVOICE_ORDER -ORA-00001: unique constraint (CROSS.SYS_C008565) violated
    ORA-02063: preceding line from PROD1
    [/pre]
       How can I to know hat Is key  ?
    using 9.2.08

    > How can I to know hat Is key  ?
    The error message doesn't give you the value.  You'll have to find it via select...where exists (or something like that).
    Or prevent the error in the first place by using MERGE (or insert...where not exists).
    (Or you can try dml error logging when you upgrade to a supported version of the database.)

  • PK with TIMESTAMP causes insert unique constraint error at DST switch

    Hi,
    I have a test that inserts rows in a table that has a TIMESTAMP in its PK.
    When inserting rows that cross over the November DST change, it tries to insert these dates:
    --- Sun Nov 02 02:00:00 EST 2008
    --- Sun Nov 02 01:00:00 EST 2008
    --- Sun Nov 02 01:00:00 EDT 2008
    This is the output of 3 different UTC dates. We can see that there are 2 x 1am, but they differ in their DST. They are really 3 different UTC dates.
    But I get this error:
    --- Expected error: ORA-00001: unique constraint (DDLTEST1.SYS_C00142622) violated
    But I can get around that error and can insert these same dates if I set my JVM to UTC. The inserts work so I suspect this to be a JDBC issue.
    I am using the Oracle Thin driver in a spring app:
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@localhost:db" />
    I can post the sample code but wonder if there is an obvious answer to this.
    Note that MySql had the same problem. I fixed it by specifying the UTC timezone in the connection string, like this:
    jdbc:mysql://[host]/[db]?useLegacyDatetimeCode=false&useTimezone=true&sessionVariables=time_zone='UTC'
    Any idea how to get around that problem without setting JVM to UTC ?
    Claude
    Edited by: user2678899 on 10 juin 2009 10:09
    I removed #2 work around which was wrong
    Edited by: user2678899 on 10 juin 2009 10:23

    Timur Akhmadeev wrote:
    Hi,
    I suspect this to be a JDBC issue.Nope, this is your schema design gap. It breaks the main principle of PK: to uniquely identify a row in a table always. Your PK doesn't satisfy it, since it depends on client's settings.Why is setting the JVM to UTC working ? This is the part that confuses me.
    I create the 3 dates in Eastern time, then change the JVM default to UTC: the 3 inserts work.
    I create the 3 dates in Eastern time, then leave the JVM to Eastern time , the 3rd insert gets the unique constraint error.
    To me, the PK principle is not broken: these are 3 different UTC dates.

  • Unique constraint error on delete/insert

    Hi,
    I am using Jdeveloper 11.1.1.3.0. I have a ADF table where we can copy lines and delete lines. I get unique constraint error when I save. Looks like the insert operation in happening before the delete operation. Is there a way to set the execution order so that the logical behaviour is delete/update/insert.
    Thanks
    SV

    Hi,
    The unquie contraint is not from the primary key. There are three columns in the table (batch_id, line_number, line_type) which must be unique. In the UI, the user can delete lines, update lines and add lines and finally click the save button that does the commit. On delete the line_number gets re-numbered. So when committing, the unique error occurs because the line number already exists. Looks like insert is happening before update/delete. I cannot do commit after each delete/update/insert. I have to do it only if the user clicks the save button in the end. Is there a way to control the order of execution?
    SR

  • Reporting exceptions on deferred constraints

    Is it possible to report exceptions on deferred constraints? I am using this mechanism to load tables in an arbitrary order and to prevent FK violations whilst loading.
    As a starting point, the script below works as expected (enabling and disabling):
    CREATE TABLE EXCEPTIONS
    ( ROW_ID ROWID
    , OWNER VARCHAR2(30)
    , TABLE_NAME VARCHAR2(30)
    , CONSTRAINT VARCHAR2(30)
    CREATE TABLE EMP( ENAME VARCHAR2(10));
    ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
    ALTER TABLE EMP DISABLE CONSTRAINT EMP_UK;
    INSERT INTO EMP VALUES ('SMITH');
    INSERT INTO EMP VALUES ('SMITH');
    ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
    SELECT * FROM EXCEPTIONS;
    However, I don't want to disable constraints, because the application may be performing DML in another session.
    So in the script below I'm deferring the constraints instead of disabling them. But how can I report the constraint violations in this scenario?
    CREATE TABLE EXCEPTIONS
    ( ROW_ID ROWID
    , OWNER VARCHAR2(30)
    , TABLE_NAME VARCHAR2(30)
    , CONSTRAINT VARCHAR2(30)
    CREATE TABLE EMP( ENAME VARCHAR2(10));
    ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
    ALTER SESSION SET CONSTRAINTS=DEFERRED;
    INSERT INTO EMP VALUES ('SMITH');
    INSERT INTO EMP VALUES ('SMITH');
    -- Which statement goes here to report constraint violations?
    SELECT * FROM EXCEPTIONS;
    The statement:
    SET CONSTRAINTS ALL IMMEDIATE;
    will validate deferred constraints and result in a SQL Error: ORA-00001: unique constraint (SCOTT.EMP_UK) violated
    But this does not tell me the rows.
    The statement:
    ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
    results in the following error, and no rows in the exceptions table:
    SQL Error: ORA-02091: transaction rolled back
    ORA-00001: unique constraint (SCOTT.EMP_UK) violated
    Is there any way to report the violations?
    At the end, I'd like to report ALL violating rows to the user.
    The best I can come up with is, for each constraint perform:
    SET CONSTRAINT EMP_UK IMMEDIATE;
    and in the exception handler explicitly query for duplicates in the table:
    SELECT ENAME FROM EMP GROUP BY ENAME HAVING COUNT(*) > 1;
    I hope there is a better way.

    I believe this will not be usable in a scenario in which the tables are loaded in the "wrong" order. The database will only be consistent after all tables have been loaded. Using DML error logging will produce false errors. Please correct me if I'm wrong.

  • ORA-00001: unique constraint error..

    Hi There,
    We were trying to do an insert when we started having ORA-00001: unique constraint error.. to speed our testing we decided to disable all the constraints on the table; however we still having the same issue.
    How can we resolve this please.
    SQL> select constraint_name,constraint_type,status from dba_constraints where table_name='MEMBER_LATEST';
    CONSTRAINT_NAME                C STATUS
    MEMBER_LATEST_PK               P DISABLED
    SYS_C0017577                   C DISABLED
    SYS_C0017576                   C DISABLED
    SYS_C0017575                   C DISABLED
    SYS_C0017574                   C DISABLED
    SYS_C0017573                   C DISABLED
    SYS_C0017572                   C DISABLED
    SYS_C0017571                   C DISABLED
    SYS_C0017570                   C DISABLED
    MEMBER_LATEST_FK               R DISABLED
    10 rows selected.
    SQL>
    SQL>
    SQL>     INSERT INTO MEMBER_LATEST (DIS_ID, TIMESTAMP, LAST_NAME, FIRST_NAME, MIDDLE_NAME, DIS_COUNT)
      2    SELECT DIS_ID, 'TEST', LAST_NAME, FIRST_NAME, MIDDLE_NAME, 0
      3    FROM MV_DIS_MEM, MV_DIS_COUNT
      4    WHERE MV_DIS_MEM.P_CODE =  MV_DIS_COUNT.P_CODE
      5    ORDER BY 1,3,4;
        INSERT INTO MEMSCH.MEMBER_LATEST (DIS_ID, TIMESTAMP, LAST_NAME, FIRST_NAME,
    ERROR at line 1:
    ORA-00001: unique constraint (MEMSCH.MEMBER_LATEST_PK) violated
    SQL>Anything else we can do please?
    Thanks

    rsar001 wrote:
    but isn't the unique index constraint part of the disabled constraints on the table as shown above?Not if index used by PK was created separately prior to PK:
    SQL> create table emp1 as select * from emp;
    Table created.
    SQL> alter table emp1
      2  add constraint emp1_pk
      3  primary key(empno);
    Table altered.
    SQL> insert into emp1 select * from emp;
    insert into emp1 select * from emp
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.EMP1_PK) violated
    SQL> alter table emp1 disable primary key;
    Table altered.
    SQL> insert into emp1 select * from emp;
    14 rows created.
    SQL> rollback;
    Rollback complete.
    SQL> alter table emp1 drop primary key;
    Table altered.
    SQL> create unique index emp1_pk on emp1(empno);
    Index created.
    SQL> alter table emp1
      2  add constraint emp1_pk
      3  primary key(empno)
      4  using index emp1_pk;
    Table altered.
    SQL> insert into emp1 select * from emp;
    insert into emp1 select * from emp
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.EMP1_PK) violated
    SQL> alter table emp1 disable primary key;
    Table altered.
    SQL> insert into emp1 select * from emp;
    insert into emp1 select * from emp
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.EMP1_PK) violated
    SQL> But by dropping index you are simply delaying the issue. Yes, you will be able to insert, but what's then? You will not be able to recreate PK - same violation error will be raised.
    SY.

  • MView refresh error on 10gR2..(unique constraint error)

    Hi. all.
    The database is 2-node RAC 10gR2 on SunOS.
    Today morining, I got the following error.
    EXEC dbms_refresh.refresh('"ODSFAB"."CURRENTWIP"');
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (ODSFAB.CURRENTWIP_GLASS_IDX) violated
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2254
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2460
    ORA-06512: at "SYS.DBMS_IREFRESH", line 683
    ORA-06512: at "SYS.DBMS_REFRESH", line 195
    ORA-06512: at line 1
    I checked both the source and target table, but there is no unique-key confliction.
    The source table has no unique index, but the target table have one unique index
    for a business purpose.
    Finally, I dropped the miew log on a source table and mview , and recreated mview
    log and mview with the same unique constraint and the same data.
    I do not understand why I got "Unique constraint error".
    Any advice will be welcomed.
    Thanks in advance.
    Have a good day.
    Best Regards.
    Message was edited by:
    user507290

    Let us say column A is the unique key on target DB and exists in source DB.
    Now, on source DB,
    - Value 'X' is inserted in col A
    - Value "X" is again inserted in col A (or updated on colA)
    - Then one of these 2 rows is deleted
    Now, "if" Oracle applies all the transactions from the source to target in the
    same sequence as they occured, there is chance you can get unique error.you do
    But, if a full refresh, there won't be error.I would say that is a very plausible explanation. Somewhat difficult to verify, in the absence of low-level auditing on the source database.
    The situation as described is a bit yucky. Is there no way of putting a unique key on the table in the source database? If not, it seems to me that this scenario is bound to re-occur.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Influence of deferred constraint to Table is mutating proble

    Hello,
    i have a question regarding the 'Table is mutating,
    Trigger/Function may not see it'-problem. I
    wondered whether a deferrable constraint can solve the problem,
    but as I tested it, it's the same
    behaviour as before.
    Situation:
    assume tables LOC_TO and TORDER and the following constraint:
    ALTER TABLE LOC_TO ADD (CONSTRAINT LT_TOID FOREIGN KEY (LT_TOID)
    REFERENCES TORDER ON DELETE CASCADE
    DEFERRABLE INITIALLY DEFERRED);
    assume a trigger on table TORDER:
    create or replace trigger tIU_TORDER_ADD
    after insert or update of TO_STATE on TORDER
    for each row
    declare
    begin
    insert
    into loc_to
    ( lt_locid,
    lt_toid )
    values
    ( 'HRL14042',
    :new.to_id )
    end tIU_TORDER_ADD;
    I thought, that on a deferred constraint at the triggered action
    no check to TORDER is done, and
    that this fact will prevent the ORACLE_ERROR ORA-04091.
    Can anyone tell me, why this doesn't work?
    Thanks
    Titus Leskien
    null

    There was a loophole in the mutating table gotcha: single row inserts in a BEFORE EACH ROW trigger were not considered mutating, but were in AFTER EACH ROW triggers. This did not apply to INSERT INTO ... SELECT ... statements, which always mutated, even if they only inserted one row.
    This is get-out is no longer included in the documentation, but as you have found still applies in the 9.2 database (and it's unlikely Oracle will have broken it in 10g).
    Cheers, APC

  • Urgent Check Constraint Error

    hi
    i have a check constraint on a table B mean Nvl(Quantity,0)>=0 but when i update a table from a trigger on insertion of another table A
    with :New.Quantity -ive it gives check constraint error.
    Please Note it does not turn the balance into negative for table B
    second because im inserting in table A then :new.quantity reffers to table A values not the table B
    why this constraint error appears.
    any body suggest
    thanks in advance

    tĦ€ §µåдŋ wrote:
    i have a check constraint on a table B mean Nvl(Quantity,0)>=0 but when i update a table from a trigger on insertion of another table A
    with :New.Quantity -ive it gives check constraint error.
    Please Note it does not turn the balance into negative for table B
    second because im inserting in table A then :new.quantity reffers to table A values not the table B
    why this constraint error appears.Not urgent at all.
    So you have a constraint on table B and then a trigger on table A attempts to update table B with a negative quantity which violates the constraint and it throws a constraint error.
    That sounds right to me. What's the problem?

  • SSIS - "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object ' tablename '. The duplicate key value is 1234 . Though there are no duplicate records.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.
    I suspect you are trying to insert modified records instead of updating.

  • Unique Constraint Error at Apply side

    We have streams configured between two databases. Source database is of Version 9.2.0.3 and target database is of 9.2.0.4
    I have a table TEST with primary key PK_TEST on column A.
    Performed the following steps on the source database:
    Step1:
    insert into test values (1);
    1 row inserted.
    Total no of lcr's propagated : 1
    Step2:
    insert into test values (1);
    ORA-00001: unique constraint (TEST_USER.PK_TEST)violated.
    Total no of lcr's propagated : 1
    Step 3:
    Commit;
    Total no of lcr's propagated : 1
    On the source database, i have only one row in the TEST table but in the target schema iam getting "ORA-00001: unique constraint" error on applying the lcr's propagated from the source. If i remove the constraint from the target table then two rows are getting inserted in the target table rather only one rows should be inserted in the target table.
    Total 3 lcr's are propagated from source to target. For Step2, 2 lcr's should be propagated but only one is propagating.
    It looks strange but this is what happening in our environment. Has anyone faced this problem before? Please let me know how to solve this problem.

    Hi,
    I believe your problem is with the transaction.
    1) First you insert a row
    2) you try to insert it again, it fails
    3) you commit your work
    When propagated to your destination, the transaction does not commit because it failed in the second.
    Try inserting, commit and inserting again. It should work that way. Or else you may need to write an error handler to ignore ORA-0001 errors and commit (which I don't think it is good practice).
    Hope this helps,

  • Help with unique constraint ERROR!!!

    This error occurs after invoking a Stored Procedure program. When it tries to insert, the PK table goes beserk:
    ORA-00001: unique constraint (HASUNI.THA_OTHER_ACTIVITY_PK) violated
    ORA-06512: at "HASUNI.POPULATE_GDW_ACTIVITY", line 203
    ORA-06512: at "HASUNI.GDW_MASTER", line 21
    ORA-06512: at line 9
    I tried to clear the PK table to get past the unique constraint error, but I can't seem to delete contents.
    PLEASE HELP!!!!

    The other queries are erroring out. It doesn't like the HASUNI.THA_OTHER_ACTIVITY_PK. It says this is an undefined table.
    Insert Statement:
    INSERT INTO HASUNI.THA_OTHER_ACTIVITY <-- line 203
    SELECT
    viewActivity.GROUPID,
    SUBSTR(viewActivity.MEMBERID,11,9)||SUBSTR(viewActivity.MEMBERID,21,9),
    viewActivity.ACTIVITYSEQUENCE,
    val_first_day,
    TO_DATE('31DEC9999'),
    viewActivity.PRODUCTID,
    viewActivity.PRODPLANTYPE,
    SUBSTR(viewActivity.MEMBERID,11,9),
    SUBSTR(viewActivity.MEMBERID,21,9),
    viewActivity.CLASSVAL,
    viewActivity.PCC,
    viewActivity.BRANCH,
    viewActivity.ARC,
    viewActivity.LOCATION,
    viewActivity.MEMBERID,
    viewActivity.DOB,
    viewActivity.GENDER,
    viewActivity.MEMBERSTATUS,
    viewActivity.CHPNID,
    viewActivity.SSN,
    NULL,
    NULL,
    SUBSTR(viewActivity.ZIPCODE,1,5),
    SUBSTR(viewActivity.ZIPCODE,7,4),
    viewActivity.ST,
    viewActivity.SOURCESYSTEMID,
    viewActivity.SOURCE,
    viewActivity.INITIATEDBY,
    viewActivity.OUTCOMES,
    viewActivity.OUTCOMESDATE,
    viewActivity.INITACTDATE,
    viewActivity.INITACTTAKEN,
    viewActivity.INITACTTAKENDATE,
    viewActivity.INITUSERID,
    viewActivity.LASTMODUSRID,
    viewActivity.LASTMODDATE,
    'HAS',
    val_last_day,
    NULL
    FROM
    HASUNI.VW_GDW_ACTIVITY viewActivity,
    HASUNI.HA_OUTREACH outreach
    WHERE
    viewActivity.MEMBERID IN (SELECT viewActivity.MEMBERID FROM HASUNI.VW_GDW_ACTIVITY viewActivity)
    AND outreach.MMBR_ID = viewActivity.MEMBERID
    AND viewActivity.INITACTTAKEN = 'OTHER'
    AND (TRUNC(viewActivity.INITACTDATE) BETWEEN val_first_day AND val_last_day
    OR (TRUNC(viewActivity.INITACTDATE) < val_first_day
    AND TRUNC(viewActivity.LASTMODDATE) BETWEEN val_first_day AND val_last_day));

  • Database Constraint Error Handling on create/edit (Struts ADF)

    Hi,
    In our project we use Struts ADF (JDeveloper 10.1.3) technology. And we're facing the following trouble with it.
    If we try to create a record that violates say Unique constraint in the database, then during commit procedure of the AppModule's Transaction an exception occurs.
    We handle this exception with our extension of DCErrorHandlerImpl. And we have to do the rollback action because the Transaction became invalid and we cannot do the commit since there was an error.
    But unfortunately appModule.getTransaction().rollback(); forces ViewObj to loose all of the newly created rows. Because of this, after pressing submit with the same (violating) data once more our edit form shows the first row in a rowset.
    Are there any ideas about what we may be doing wrong?
    Any standard approaches on database constraint error handling?
    The "before/after commit/rollback" approach is very effort-consuming because we have a lot of views in our app and tracking all of them may become a nightmare in future.
    Thanks in advance.
    Regards,
    Larry

    Hi Steve!
    I'm using Postgree.
    Here is StackTrace
    06/06/27 09:52:24 Commit
    oracle.jbo.DMLException: JBO-26041: Failed to post data to database during "Insert": SQL Statement "INSERT INTO public.test_tb(id,name,org_code) VALUES (?,?,?)".
         at oracle.jbo.server.BaseSQLBuilderImpl.doEntityDML(BaseSQLBuilderImpl.java:481)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:5731)
         at com.yukon.adf.postgre.entities.PostgreEntityImpl.doDML(PostgreEntityImpl.java:22)
         at com.yukon.adf.postgre.entities.PostgreSequenceEntityImpl.doDML(PostgreSequenceEntityImpl.java:58)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:4531)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2993)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2804)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1968)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2170)
         at view.actions.ListTestPageController.onCommit(ListTestPageController.java:32)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.adf.controller.v2.lifecycle.PageController.invokeEventMethod(PageController.java:110)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.handleEvent(PageLifecycleImpl.java:950)
         at oracle.adf.controller.v2.struts.lifecycle.StrutsPageLifecycle.handleEvent(StrutsPageLifecycle.java:238)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.processComponentEvents(PageLifecycleImpl.java:322)
         at oracle.adf.controller.v2.lifecycle.PageController.processComponentEvents(PageController.java:54)
         at oracle.adf.controller.v2.lifecycle.Lifecycle$3.execute(Lifecycle.java:275)
         at oracle.adf.controller.v2.lifecycle.Lifecycle.executePhase(Lifecycle.java:116)
         at oracle.adf.controller.v2.lifecycle.LifecycleProcessor.execute(LifecycleProcessor.java:100)
         at oracle.adf.controller.v2.struts.actions.DataAction.execute(DataAction.java:123)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:629)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.sql.SQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
         at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
         at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
         at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330)
         at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:282)
         at oracle.jbo.server.BaseSQLBuilderImpl.doEntityDML(BaseSQLBuilderImpl.java:352)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:5731)
         at com.yukon.adf.postgre.entities.PostgreEntityImpl.doDML(PostgreEntityImpl.java:22)
         at com.yukon.adf.postgre.entities.PostgreSequenceEntityImpl.doDML(PostgreSequenceEntityImpl.java:58)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:4531)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2993)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2804)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1968)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2170)
         at view.actions.ListTestPageController.onCommit(ListTestPageController.java:32)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.adf.controller.v2.lifecycle.PageController.invokeEventMethod(PageController.java:110)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.handleEvent(PageLifecycleImpl.java:950)
         at oracle.adf.controller.v2.struts.lifecycle.StrutsPageLifecycle.handleEvent(StrutsPageLifecycle.java:238)
         at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.processComponentEvents(PageLifecycleImpl.java:322)
         at oracle.adf.controller.v2.lifecycle.PageController.processComponentEvents(PageController.java:54)
         at oracle.adf.controller.v2.lifecycle.Lifecycle$3.execute(Lifecycle.java:275)
         at oracle.adf.controller.v2.lifecycle.Lifecycle.executePhase(Lifecycle.java:116)
         at oracle.adf.controller.v2.lifecycle.LifecycleProcessor.execute(LifecycleProcessor.java:100)
         at oracle.adf.controller.v2.struts.actions.DataAction.execute(DataAction.java:123)
         at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:629)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

  • Toplink 10.1.3.1 Unique Constraint error

    Hi All,
    I'm working with toplink 10.1.3.1 using JDeveloper 10.1.3.1.
    When I'm using the Sequence in the toplink work bench, I'm getting the unique constraint error.
    What i did was, I checked the "Use sequencing" check box and filled the sequence name , table name and field in the toplink workbench wizard.
    And I kept true for "Use Native Sequencing" in the sequence of login tab for sessions.xml default file. And checked the preallocation Size and set to the minimum value of the sequence. I didn't checked the "Table", "Name Field" and "Counter Field" check boxes.
    The sequence is getting incremented for every execution. Its not getting the actual sequence current value. I don't know whether the value is getting cached.
    for example if the actual sequence number in the database is 1740
    but when I am running the toplink query It is generating the sequence number like 1738 and it is giving the Unique constraint when I am clicking on the button for three times (ie 1739,1740,1741)it is inserting successfully into the database.
    But when I am running the application again then it is generating the sequence number as 1739 I am unable to understand where I am going wrong.
    If I test The sequence in SQL Work Sheet it was working fine.
    could anyone suggest me the correct way of using the sequence in the toplink workbench.
    the Sequence was created using JDeveloper wizard with Increment 1.
    Thanks in advance,
    regards,
    Satish Dasari.

    Hi,
    Satish,Thanks for your reply.
    Let me tell the scenario. I have two tables A and B. First I am inserting an event_no in table A. and after that I read the data from table A including event_no and I am going to insert it into table B. Rarely I am getting an exception like Unique constraint violation error.
    I kept native sequencing true,preallocation size 1, Min value=1, Max-value=9999999, increment by 1, cache size=10, Enabled refresh only if new version.
    What are all the values that i need to be changed in order to recover from this error. Our application is running in a load balancing environment.
    Note: I am not able to simulate this in my desktop environment.
    Regards,
    P.Prasanna.

  • Deferred constraints &  XAExceptions details

    When executing an XA transaction on Oracle 8i with a J2EE server, we are not getting enough details in the OracleXAException that occurs as a result of a deferred constraint being violated (during the commit).
    We're getting a oracle.jdbc.xa.OracleXAException (wrapped inside a TransactionRolledBackException), and upon further inspection I can call the OracleXAException methods:
    getOracleError() : int
    getOracleSQLError() : int
    I cannot get any textual details about the error (ie. which constraint was violated).
    Do other version of Oracle provide more details during XA transaction failures?
    Thanks,
    M

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by SAMEER DESHPANDE ([email protected]):
    Hello
    I would like to know the use of Deferred Constraints.
    At the time of COMMMIT, the Oracle ROLLBACKS the transaction if I set "SET CONSTRAINT ALL DEFERRED;"...
    What is the use of DEFERRED CONSTRAINTS...?
    Thanks
    Sameer<HR></BLOCKQUOTE>
    You can do "SET CONSTRAINT ALL IMMEDIATE" before committing. That statement will raise an error, without rolling back the transaction, if there are violated constraints.

Maybe you are looking for

  • Writing the result to seperate HTML page.

    Hello, I want a program in which I compare 3 different files and display the result. Now I want to write/save the result into a seperate HTML/pdf file. Can somebody help me in this respect. Thanks in advance, Nirmal Kumar Bhogadi

  • What makes a Scalar Valued Function "deterministic"

    Hi all, I have the following column definition in a CREATE TABLE statement: [Batch] AS [ÜNB] + '-' + [TypeOfData] + ' {' + CONVERT(NCHAR(4), [Validity Year]) + '} {' + CAST([Actuality Year] AS CHAR(4)) + '-' + IIF([Actuality Month] < 10, '0', '') + C

  • Include SQLite in adobe air installer package

    Is it possible to have a SQLite DB included in the air installer package? I don't want to have the DB created when the application runs, I want to install it when the application installs. I also want to install it to the All Users>Application Data f

  • Lens profile for Fuji HS10

    Hi everybody, hope this is the place to finally solve my problem. I bought myself a Fujifilm HS10 some time ago (don't laugh at me just for that). And the Raw-Converter that comes with it (of course) works perfectly with regards to distortion correct

  • MS visual studio MFC interface for PCIe6321

    I have DAQ card PCIe6321. I have an application in MS visual studio 2010 using c++ and MFC for GUI. I want to access the inputs and outputs using this application. How can I avoid using LABview and direclty use my application to acces these IO's? Is