Handling unique constraint exception

Hi,
I have a problem with handling constraint exception. I'm wondering is there a way to get the value that violates unique constraint. Use case is following, user creates document and then adds 50 records and manually enters inventory and serial numbers that should be unique he tries to commit but since he entered let's say inventory number that already exists in database I get exception and I can only show him error message "you've entered non unique inventory or serial numbers" so then he has to go record by record and try to figure where is the mistake. it would be much easier if I could tell him that there's a duplicate inventory and serial number in record number 34. is this possible?
thanks in advance,
Tomislav.

Tomislav,
May be a good case to use a custom DBTransactionImpl, as detailed [url http://forums.oracle.com/forums/thread.jspa?threadID=700740&tstart=0]here. Something like this, perhaps (just off the top of my head):
  public void postChanges(TransactionEvent te)
    try
      super.postChanges(te);
    catch (DMLConstraintException ex)
      Row r = ex.getEntityRow();
      AttributeDef attrs[] = r.getStructureDef().getAttributeDefs();
      int numAttrs = attrs.length;
      String msg = "Duplicate key found. Primary key values: ";
      for (int i = 0; i < numAttrs; i++)
        if (attrs.isPrimaryKey())
msg = msg + attrs[i].getName() + ":" + r.getAttribute(i).toString() + " ";
throw new JboException(msg);
Note that this code would catch all DML exceptions, not just unique key violations. That would be left as an exercise for the reader ;)
John

Similar Messages

  • TopLink inserts when it should update, unique constraint exception

    The title says most of it. I am creating a series of objects and then updating them in rapid succession. It would be great to handle all the values during the insert, but it's not possible for this process. The majority of the time, the cached object is updated correctly and no problem occurs, but every once in a while TopLink tries to re-insert the previously inserted object, instead of updating it. Obviously this throws a unique constraint exception for the PK, and boots me out of the process.
    I can refreshObject and then it works fine. I'm looking for the underlying cause though. I want to be able to use the cache!
    Thanks!!
    Aaron
    Oracle JDBC driver Version: 10.2.0.3.0
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    TopLink Release-Designation: 10g Release 3

    Hello,
    How are you obtaining these objects to update them? The likely cause is that you are running out of memory and the objects in the shared identity map are getting garbage collected due to weak references. This means that when they get registered, TopLink can't find them in the cache so assumes they are new (the default existence check is check cache).
    If this is the case, there are a few options.
    1) Increase the size of the cache for the class in question to something more appropriate for your application, or use a fullIdentyMap so nothing ever gets pushed out. Of course, a FullIdentityMap should not be used lightly as it prevents its objects from beign gc'd and has consequences to related objects as described in:
    Caching Causing Memory Leak Effect
    Both these options will require more memory resources though, so if garbage collection is running and clearing out the references because you are already low on memory, this might make GC need to run more frequently
    2) Increase the JVM memory. This assumes completely that GC is clearing out the unused weak references from your cache because it is low on memory - GC can still occur so it doesn't guarantee the problem will be any better
    3) Read in the object through the UnitofWork before making changes (instead of using RegisterObject on existing objects), use the registerExistingObject for known existing objects or use the uow mergeClone method. Merge should cause the object to be read from the database if it is not in the cache, but it depends on the existence options used
    Best Regards,
    Chris

  • Post Process Event Handler ----Unique Constraint Violation--Create User

    Hi Evryone..
    I am creating the user using the create user request template and there is one level of approval for this.
    I have one pre process event handler which populates one field A and one post process event handler which updates some 3 fields in the user form .
    In request template itself we had placed value as "ABC" for field B and this field B will be overridden in the post process event handler with Value as "XYZ" .
    Now when i raise the request the user is getting created in OIM but the value XYZ is not getting replaced in the field B.
    Below are the errors which i got in the logs while executing post process event handler :
    <Mar 28, 2012 10:25:58 AM CDT> <Warning> <oracle.iam.callbacks.common> <IAM-2030146> <[CALLBACKMSG] Are applicable policies present for this async eventhandler ? : false>
    <Mar 28, 2012 10:25:59 AM CDT> <Warning> <org.eclipse.persistence.session.oim> <BEA-000000> <
    Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (DEV_OIM.UK_UAR_ATTR_NAME_VALUE) violated
    Error Code: 1
    Call: INSERT INTO USR_ATTRIBUTE_RESERVATIONS (UAR_RESERVATION_KEY, UAR_ATTRIBUTE_NAME, CREATED_BY, CREATED_ON, DATA_LEVEL, UAR_REQUEST_ID, UAR_RESERVED_VALUE, UPDATED_BY, UPDATED_ON) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    bind => [10, User Login, null, null, null, 10, DUMMY14, null, null]
    Query: InsertObjectQuery([email protected]658269)
    Exception at usrIntf.updateUser IAM-3050128 : Cannot reserve user attribute User Login with value DUMMY14 in OIMDB. Corresponding request ID is 10.:User Login:DUMMY14:10
    I checked reservations table and there are no records in that table.
    Has any one faced this issue..if so how it can be resolved..

    Are you trying to update the User ID? As far as I know during create user requests, OIM reserves the user login as it goes through approval and you cannot update that directly I think. I haven't tried it but can you tell me which fields you are prepopulating and which are you updating? Are there any OOTB fields in this or UDF?
    -Bikash

  • How to handle ORA-00001: unique constraint in EXCEPTION block?

    Hi,
    Is there a specific exception thats raised when ORA-00001: unique constraint error occurs?

    SQL> create table test(id number primary key);
    Table created.
    SQL> set serverout on
    SQL> declare
      2   ex exception;
      3   pragma exception_init(ex,-1);
      4  begin
      5   insert into test values(1);
      6  exception
      7   when ex then
      8    dbms_output.put_line('dup');
      9   when others then
    10    raise;
    11  end;
    12  /
    dup                                                                            
    PL/SQL procedure successfully completed.
    <br>
    <a href ="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/errors.htm#LNPLS00703">Predefied exceptions </a>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to Catch Unique Constraint in Exception

    Hi,
    I am writing a trigger TR_EMP on a table EMP which has columns EMP_ID, EMP_NAME, ALT_EMP_ID.
    Now I am updating ALT_EMP_ID for an EMP_ID(PK) which is unique.
    If ALT_EMP_ID is null
    then
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;As this ALT_EMP_ID is unique, same ID shouldn't be inserted again here. When data being inserted with 2 different sessions for 2 different EMP_ID there is a possible chance of inserting same ALT_EMP_ID for both which results in Unique error. I need to handle this exception. DUP_VAL_ON_INDEX or OTHERS Execption not able to handle this.
    Can you help me out on how to handle such exception?

    >
    jeneesh wrote:
    I am able to use dup_val_on_index
    >
    Can you please write an Exception for this query?
    If ALT_EMP_ID is null
    then     
          :new.ALT_EMP_ID = l_alt_emp_id;
    end if;jeneesh wrote:
    Moreover, what is your requirement? This design seems to be flawed. If you can explain teh actual requirement, forum members will be able to help you better..
    >
    Alternate Emp ID will be populated for Every employee. If on a same session when this ID is populated for 2 different Emplyoees then it will throw Unique constraint error, which should be handled.

  • Trp the exception ORA-00001: unique constraint

    Want to trap the exception
    ORA-00001: unique constraint (SCHEMA.CONSTRAINT_NAME) violated So can any one tell me the Exception name (like NO_DATA_FOUND).

    You can map error numbers to exception names, although this isn't good practice with errors that are in the pre-defined exception list.
    SQL> create table t (id NUMBER, txt VARCHAR2(10));
    Table created.
    SQL> alter table t add primary key (id);
    Table altered.
    SQL> insert into t values (1, 'A');
    1 row created.
    SQL> insert into t values (1, 'B');
    insert into t values (1, 'B')
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.SYS_C0053239) violated
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    exc_unique_fail exception;
      3    pragma exception_init(exc_unique_fail, -1);
      4  begin
      5    insert into t values (1, 'B');
      6    dbms_output.put_line('insert successful');
      7  exception
      8    when exc_unique_fail then
      9      dbms_output.put_line('unique constraint failure detected');
    10* end;
    SQL> /
    unique constraint failure detected
    PL/SQL procedure successfully completed.
    SQL>

  • (Error) ORA-00001: unique constraint (WHSE_DBA.PK_DELPHI_TRANS_FACT) violat

    I have a stored proc which runs every night. The stored proc is giving a unique constraint violation.
    (Error) ORA-00001: unique constraint (WHSE_DBA.PK_DELPHI_TRANS_FACT) violated.
    Any idea about how to debug this.

    I want to create an error table on the stored proc shown below. I know I have to add something in the exceptions. Can anyone give me the commands and where to add it.
    CREATE OR REPLACE PROCEDURE WHSE_DBA.DM_LD_DELPHI_TRANS_FACT
    IS
    -- VARIABLE DECLARATIONS
    LAST_LOAD_DATE                   DATE;
    INSERTCOUNT                 NUMBER:=0;
    -- LOGGING VARIABLES AND CONSTANTS
    TARGETTABLE                 CONSTANT VARCHAR2(20):='DELPHI_TRANS_FACT';
    MSGUNKNOWNERR               CONSTANT VARCHAR2(20):='Error';
    NBRIGNOREERR                CONSTANT NUMBER:=12541;
    DEFDATE                     CONSTANT DATE:='01-OCT-2006';
    ERRDESCRIPTION              VARCHAR2(255);
    V_DELPHI_TRANS_TOTAL            NUMBER;
    V_DELPHI_TRANS_FACT_TOTAL   NUMBER;
    BEGIN
    -- LOOK UP LAST LOADED RECORD
    SELECT NVL(MAX(SNAPSHOT_DATE),DEFDATE)
    INTO LAST_LOAD_DATE
    FROM DELPHI_TRANS_FACT;
    -- * LOAD ALL DIMENSION TABLES
    -- BUDGET_YR_DIMENSION
    INSERT INTO BUDGET_YR_DIMENSION (BUDGET_YEAR, SNAPSHOT_DATE)
    (SELECT DISTINCT BUD_YR, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM BUDGET_YR_DIMENSION
    WHERE BUDGET_YEAR=OUTER.BUD_YR));
    -- EFF_DATE_DIMENSION
    INSERT INTO EFF_DATE_DIMENSION (PAID_FIS_YEAR, PAID_QTR, EFFECTIVE_DATE, SNAPSHOT_DATE)
    (SELECT DISTINCT CVT_DATE_TO_FISCAL_YEAR(EFF_DT), PD_QTR, EFF_DT, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM EFF_DATE_DIMENSION
    WHERE EFFECTIVE_DATE=OUTER.EFF_DT));
    -- PROC_DATE_DIMENSION
    INSERT INTO PROC_DATE_DIMENSION (PROCESS_DATE, SNAPSHOT_DATE)
    (SELECT DISTINCT PROC_DT, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM PROC_DATE_DIMENSION
    WHERE PROCESS_DATE=OUTER.PROC_DT));
    -- ORG_DIMENSION
    INSERT INTO ORG_DIMENSION (ORG,COST_CTR,SNAPSHOT_DATE)
    (SELECT DISTINCT ORG, CC_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM ORG_DIMENSION
    WHERE ORG=OUTER.ORG));
    -- BPAC DIMENSION
    INSERT INTO BPAC_DIMENSION (BPAC, AFC_CD, PE_CODE, SNAPSHOT_DATE)
    (SELECT DISTINCT BPAC, AFC_CD, PE, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM BPAC_DIMENSION
    WHERE BPAC=OUTER.BPAC));
    -- FUND DIMENSION
    INSERT INTO FUND_DIMENSION (FUND,APPROP_CD,LIM_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT FUND, APPROP_CD, APPLIM_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM FUND_DIMENSION
    WHERE FUND=OUTER.FUND));
    -- OBJ_CD_DIMENSION
    INSERT INTO OBJ_CD_DIMENSION (OBJ_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT OC_CD, SYSDATE
    FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM OBJ_CD_DIMENSION
    WHERE OBJ_CD=OUTER.OC_CD));
    -- GLA DIMENSION
    INSERT INTO GLA_DIMENSION (GLA_CD,SNAPSHOT_DATE)
    (SELECT DISTINCT GLA, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM GLA_DIMENSION
    WHERE GLA_CD=OUTER.GLA));
    -- PROJECT_TASK_DIMENSION
    INSERT INTO PROJECT_TASK_DIMENSION (PROJECT_NO,TASK_NO,SNAPSHOT_DATE)
    (SELECT DISTINCT PROJ_NBR, TASK_NBR, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM PROJECT_TASK_DIMENSION
    WHERE PROJECT_NO=OUTER.PROJ_NBR
      AND TASK_NO=OUTER.TASK_NBR));
    -- TRANS_DESC_DIMENSION
    INSERT INTO TRANS_DESC_DIMENSION (DESCRIPTION,SNAPSHOT_DATE)
    (SELECT DISTINCT DESCR, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM TRANS_DESC_DIMENSION
    WHERE DESCRIPTION=OUTER.DESCR
    AND OUTER.DESCR IS NOT NULL));
    -- SUPPLIER_DIMENSION
    INSERT INTO SUPPLIER_DIMENSION (SUPPLIER_NAME, SNAPSHOT_DATE)
    (SELECT DISTINCT VENDOR_NAME, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM SUPPLIER_DIMENSION
    WHERE SUPPLIER_NAME=OUTER.VENDOR_NAME));
    -- DELPHI_INV_DIMENSION
    INSERT INTO DELPHI_INV_DIMENSION (INVOICE_NO, SNAPSHOT_DATE)
    (SELECT DISTINCT INV_NO, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM DELPHI_INV_DIMENSION
    WHERE INVOICE_NO=OUTER.INV_NO));
    -- DELPHI_PO_DIMENSION
    INSERT INTO DELPHI_PO_DIMENSION (PO_NO, SNAPSHOT_DATE)
    (SELECT DISTINCT PO_NO, SYSDATE FROM DELPHI_TRANS OUTER
    WHERE NOT EXISTS
    (SELECT 1
    FROM DELPHI_PO_DIMENSION
    WHERE PO_NO=OUTER.PO_NO));
    -- TEMPORARILY DISABLE KEY FOR FASTER LOADING
    DB_MISC.PRO_EXE_DDL('ALTER TABLE DELPHI_TRANS_FACT DISABLE CONSTRAINT PK_DELPH_TRANS_FACT');
        -- MOVE DATA INTO TABLE
         INSERT INTO DELPHI_TRANS_FACT (BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY,
         EFF_DATE_KEY, PROC_DATE_KEY, PROJECT_TASK_KEY, BUDGET_YR_KEY, DELPHI_TRANS_DESC_KEY,
         BALANCE, COMMIT_AMT, UDO_AMT, AEU_AMT, AEP_AMT, OBLIGATION_AMT, SNAPSHOT_DATE,
         SUPPLIER_KEY, DELPHI_INV_KEY, DELPHI_PO_KEY)
         (SELECT BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY, EFF_DATE_KEY, PROC_DATE_KEY,
         PROJECT_TASK_KEY, BUDGET_YR_KEY, TRANS_DESC_KEY, SUM(BAL), SUM(COMMIT_AMT), SUM(UDO_AMT),
         SUM(AEU_AMT), SUM(AEP_AMT), SUM(OBLIGATION_AMT), MAX(SYSDATE), SUPPLIER_KEY, DELPHI_INV_KEY,
         DELPHI_PO_KEY
         FROM BPAC_DIMENSION, ORG_DIMENSION, FUND_DIMENSION, OBJ_CD_DIMENSION, GLA_DIMENSION,
        EFF_DATE_DIMENSION, PROC_DATE_DIMENSION, PROJECT_TASK_DIMENSION, BUDGET_YR_DIMENSION,
         TRANS_DESC_DIMENSION, DELPHI_TRANS,     SUPPLIER_DIMENSION, DELPHI_INV_DIMENSION, DELPHI_PO_DIMENSION
         WHERE DELPHI_TRANS.SNAPSHOT_DATE>LAST_LOAD_DATE
         -- JOIN WITH BPAC_DIMENSION
        AND DELPHI_TRANS.BPAC=BPAC_DIMENSION.BPAC
         -- JOIN WITH ORG_DIMENSION
         AND DELPHI_TRANS.ORG = ORG_DIMENSION.ORG
         -- JOIN WITH FUND_DIMENSION
         AND DELPHI_TRANS.FUND = FUND_DIMENSION.FUND
         -- JOIN WITH OBJ_CD_DIMENSION
         AND DELPHI_TRANS.OC_CD=OBJ_CD_DIMENSION.OBJ_CD
         -- JOIN WITH GLA_DIMENSION
         AND  DELPHI_TRANS.GLA=GLA_DIMENSION.GLA_CD
         -- JOIN WITH EFF_DATE_DIMENSION
         AND DELPHI_TRANS.EFF_DT=EFF_DATE_DIMENSION.EFFECTIVE_DATE
         -- JOIN WITH PROC_DATE_DIMENSION
         AND DELPHI_TRANS.PROC_DT=PROC_DATE_DIMENSION.PROCESS_DATE
         -- JOIN WITH PROJECT_TASK_DIMENSION
         AND (DELPHI_TRANS.PROJ_NBR=PROJECT_TASK_DIMENSION.PROJECT_NO
         AND DELPHI_TRANS.TASK_NBR=PROJECT_TASK_DIMENSION.TASK_NO)
         -- JOIN WITH BUDGET_YR_DIMENSION
         AND DELPHI_TRANS.BUD_YR=BUDGET_YR_DIMENSION.BUDGET_YEAR          
         -- JOIN WITH  TRANS_DESC_DIMENSION
         AND DELPHI_TRANS.DESCR=TRANS_DESC_DIMENSION.DESCRIPTION
         -- JOIN WITH SUPPLIER_DIMENSION
         AND DELPHI_TRANS.VENDOR_NAME=SUPPLIER_DIMENSION.SUPPLIER_NAME
         -- JOIN WITH DELPHI_PO_DIMENSION
         AND DELPHI_TRANS.PO_NO=DELPHI_PO_DIMENSION.PO_NO
         -- JOIN WITH DELPHI_INV_DIMENSION
         AND DELPHI_TRANS.INV_NO=DELPHI_INV_DIMENSION.INVOICE_NO
         GROUP BY BPAC_KEY, ORG_KEY, FUND_KEY, OBJ_CD_KEY, GLA_KEY, EFF_DATE_KEY, PROC_DATE_KEY,
         PROJECT_TASK_KEY, BUDGET_YR_KEY,TRANS_DESC_KEY, SUPPLIER_KEY, DELPHI_INV_KEY, DELPHI_PO_KEY);
    -- COUNT AFFECTED RECORDS
    INSERTCOUNT:=0+SQL%ROWCOUNT;
    -- RE-ENABLE KEY CONSTRAINT
    DB_MISC.PRO_EXE_DDL('ALTER TABLE DELPHI_TRANS_FACT ENABLE VALIDATE CONSTRAINT PK_DELPH_TRANS_FACT');
    -- STORE RESULTS OF OPERATION
    IF INSERTCOUNT>0 THEN
      DB_MISC.LOGFAILURE_EX('none', 'none', INSERTCOUNT||' new records loaded successfully.', TARGETTABLE, 'DM_LD_DELPHI_TRANS_FACT', FALSE);
    END IF;
    --- COMPARE BALANCE TOTAL FROM DELPHI_TRANS TABLE AND DELPHI_TRANS_FACT TABLE
    SELECT SUM(BAL) INTO V_DELPHI_TRANS_TOTAL
    FROM DELPHI_TRANS ;
    SELECT SUM(BALANCE) INTO V_DELPHI_TRANS_FACT_TOTAL
    FROM DELPHI_TRANS_FACT ; 
    VALIDATE_LOAD(V_DELPHI_TRANS_TOTAL,V_DELPHI_TRANS_FACT_TOTAL); 
    -- EXCEPTION HANDLING ROUTINES * * * * * * * * * * * * * * * * * * * * * *
    EXCEPTION
        WHEN OTHERS THEN
          ROLLBACK;
          IF SQLCODE!=NBRIGNOREERR THEN
            ERRDESCRIPTION:=SQLERRM;
            -- CALL ROUTINE TO PROCESS ERROR
            DB_MISC.LOGFAILURE_EX('none', 'none', ERRDESCRIPTION, TARGETTABLE, 'DM_LD_DELPHI_TRANS_FACT', TRUE);
            COMMIT;
          END IF;
    -- END EXCEPTION HANDLING ROUTINES * * * * * * * * * * * * * * * * * * * * * *
    END

  • Insert called before delete in a collection with unique constraint

    Hi all,
    I have a simple @OneToMany private mapping:
    private Collection<Item> items;
    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
    public Collection<Item> getItems() {
    return items;
    public void setItems(Collection<Item> items) {
    this.items = items;
    public void customize(ClassDescriptor classDescriptor) throws Exception {
    OneToManyMapping mapping = (OneToManyMapping)
    classDescriptor.getMappingForAttributeName("items");
    mapping.privateOwnedRelationship();
    I have a unique constraint on my Items table that a certain value cannot be duplicated.
    My problem appears when I remove a previously saved item from the collection and add a new item containing the same data, at the same time.
    After I save the parent and do a flush, I receive SQLIntegrityConstraintViolationException because TopLink performs first an insert query instead of deleting the existing item.
    I tested the application and everything went fine with: remove item / save parent / insert item / save parent
    I checked on the Internet and the documentation but didn't find anything similar to my problem. I tried debugging TopLink's internal calls but I'm missing some general ideas about all the inner workings and don't know what to look for. I use TopLink version: Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))
    Does anyone have a hint of what to look for?
    Edited by: wise_guybg on Sep 25, 2009 4:01 PM
    Edited by: wise_guybg on Oct 5, 2009 11:22 AM

    Thank you for the suggestions James
    As I mentioned briefly I have done some debugging but couldn't understand how collections are updated. What I did find out is that setShouldPerformDeletesFirst() doesn't come into play in this case because this is not a consecutive change on entities.
    What I have in my case is a collection inside an entity that the user has tampered with and now TopLink has to do a merge. I cannot call flush() in the middle since the user has not approved that the changes made to the entity should be saved.
    I see that for TopLink it's not easy to figure out the order in which changes were made to a collection. Here is pseudo-code of when the constraint is touched:
    entity.items.remove(a)
    entity.items.add(b)
    merge(entity)
    And here is code that executes without a problem:
    entity.items.remove(a)
    merge(entity)
    entity.items.add(b)
    merge(entity)
    So once again, I think that collection changes are managed differently but I don't find a way to tell TopLink how to handle them. Any ideas?

  • HOWTO: Add a UNIQUE constraint to a populated column

    Here is the way to add a unique constraint to a populated column, ensuring that the existing values are unique as well.
    ALTER TABLE t1
    ADD CONSTRAINT t1_uk UNIQUE (col1,col2)
    EXCEPTIONS INTO my_exceptions
    /If the alter table statement fails this will populate the MY_EXCEPTIONS table with the rows that contain duplicate values for (col1,col2). These are identified by ROWID. We can then chose to:
    [list]
    [*]delete rows with a bad key;
    [*]amend the values of the key columns;
    [*]re-apply the constraint with the NOVALIDATE option.
    [list]
    We should be wary of choosing the NOVALIDATE option. There's usually a good reason why the unique constraint is required and we should not circumvent it. Apart from anything else, Oracle allows us to build foreign keys referencing NOVALIDATE unique keys. This could result in child rows that have two parents, which is normal in biology, but very wrong in a database.
    NOVALIDATE is useful in datawarehouses and suchlike, because little updating occurs and the data integrity issues are of less imporatance. I don't think it ought to be used in OLTP situations. The code example at the end of this posting illustrates why we should exercise caution with NOVALIDATE.
    Once we have handled the duplicate values we can re-run the alter table statement and apply the constraint.
    If you don't already have an EXCEPTIONS table (it can be called anything, it's the structure that counts) you may need to run (or get a DBA to run) a script called UTLEXCPT.SQL, which will be in the $ORACLE_HOME/rdbms/admin directory.
    Cheers, APC
    SQL> SELECT col1, col2, col3 FROM t1;
          COL1       COL2       COL3                                               
             1          1          0                                               
             2          1          0                                               
             2          1          0                                               
    SQL> SELECT col1, col2, cola FROM t2;
          COL1       COL2 COLA                                                     
             1          1  I'm child #1                                                        
             1          1  I'm child #2                                                        
             2          1  I'm child #3                                                        
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2);
    ALTER TABLE t1 ADD CONSTRAINT t1_uk UNIQUE (col1, col2)
    ERROR at line 1:
    ORA-02299: cannot validate (TST2.T1_UK) - duplicate keys found We can't add a unique key, so we decide to use the NOVALIDATE clause.
    SQL> CREATE INDEX t1_i ON t1(col1, col2);
    Index created.
    SQL> ALTER TABLE t1
      2  ADD CONSTRAINT t1_uk UNIQUE (col1, col2) ENABLE NOVALIDATE;
    Table altered.
    SQL> INSERT INTO t1 VALUES (2, 1, 1);
    insert into t1 values (2, 1, 1)
    ERROR at line 1:
    ORA-00001: unique constraint (TST2.T1_UK) violated Well, we can't add any more duplicate keys, so that's alright isn't it? Nope. We can add a foreign key to table T2 referencing T1 but we don't know which row in T1 is the parent of the rows in T2.
    SQL> ALTER TABLE t2
      2  ADD CONSTRAINT t2_t1_fk foreign key  (col1, col2)
      3  REFERENCES t1(col1, col2)
    Table altered.
    SQL> SELECT rowid FROM t1 WHERE col1 = 2;
    ROWID                                                                          
    AAAVnMAANAAAB96AAB                                                             
    AAAVnMAANAAAB96AAC                                                             
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL> ROLL
    Rollback complete.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAC';
    1 row deleted.
    SQL> DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB';
    DELETE FROM t1 WHERE rowid = 'AAAVnMAANAAAB96AAB'
    ERROR at line 1:
    ORA-02292: integrity CONSTRAINT (TST2.T2_T1_FK) violated - child record found
    SQL>  ROLL
    Rollback complete.
    Why this matters: queries joining child and parent tables return more rows than we'd expect normally.
    SQL> SELECT t2.cola
      2  FROM   t2
      3  WHERE  t2.col1 = 2
      4  and    t2.col2 = 1;
    COLA                                                                           
    I'm child #3                                                                   
    SQL> SELECT t2.cola, t1.col4
      2  FROM   t1, t2
      3  WHERE  t2.col1 = 2
      4  AND    t2.col2 = 1
      5  AND    t1.col1 = 2
      6  AND    t2.col2 = 1;
    COLA                    COL4                                                   
    I'm child #3            I'm the daddy                                          
    I'm child #3            No, I'm the daddy!!                                    
    SQL> Caveat emptor
    This posting is issued on behalf of the Rogue Moderators. It is posted with the best of intentions but is not guaranteed in any way, shape or form. In particular, the code is presented "as is" and you assume full responsibility for running it on your system. Furthermore, you must not download and install software from the internet unless you know what you are doing and have the permission of whoever owns your system. It was never this hard for the Lone Ranger.

    Hi,
    You can not create unique key with duplicate values as you know. Now if you want to create unique key then you have to delete duplicate records from the table but this again if you can afford to delete because this data may be more importante to you and you can not delete any record.
    or you can use ENABLE NOVALIDATE option of oracle explain by Tom on below link.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:8806498660292
    or if you dont want to use Tom's way then you go with primary key like
    Drop old primary key if there is already on the column.
    create new primary key with enable novalidate option.

  • JDBC Adapter: unique constraint

    Hi,
    my scenario: IDoc -> XI -> JDBC.
    I would like to know whether the data processing on my Oracle database was successful or not. If an unique constraint fails on oracle (i have test it)
    the idoc has status successful although (XI: SXMB_MONI) . how i can make sure, that my idoc is in error state, if a unique constraint or any other error @oracle occurs ??
    Note: JDBC is async
    Thanks
    Sebastian

    Hi,
    Few options~~
    1. Make a Synch Call to the JDBC Insert so that you will get a response back with the Insert_Count etc. Wrap the SEND SYNCHRONOUS step with an Exception handler block of the BPM. If there is an Unique key violation, the Exception handler block of the BPM will be trigered. if everything is succesful, then terminate your BPM with the Send Synch call itself. No other step needed after this.
    2.If you do not want to complicate your scenario by using a BPM , I would suggest that you continue with the existing IDOC --> JDBC scenario and you use adapter Engine Alerts of XI's alerts framework to trigger a notification when there is the error in your JDBC adapter.
    Regards,
    Bhavesh
    What you can do is

  • Unique Constraint causes AppSetRollbackOnlyException

    I have declared a unique constraint using the following annotation.
    @Column(name="classname",columnDefinition="varchar(1024)",nullable=false,unique=true)
    When trying to insert duplicate entities with the same name, essentially violating the constrain the following exception appears. It is not directly obvious what is causing this exception and it only is thrown during the commiting of the transaction, rather during the persist() which makes it difficult to intercept and handle.
    <24-Jan-2008 11:01:33 o'clock GMT> <Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB com.thunderhead.simple.SimpleBean.process(int)],Xid=BEA1-0660A26EF337BD76B51F(9378830),Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyException],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=60,SCInfo[wl_server+examplesServer]=(state=rolledback),properties=({weblogic.transaction.name=[EJB com.thunderhead.simple.SimpleBean.process(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=examplesServer+192.168.2.165:7001+wl_server+t3+, XAResources={examples-demoXA, WLStore_wl_server_WseeFileStore, examples-demoXA-2, WLStore_wl_server_exampleJDBCStore, examples-multiDataSource-demoXAPool, WLStore_wl_server__WLS_examplesServer},NonXAResources={})],CoordinatorURL=examplesServer+192.168.2.165:7001+wl_server+t3+): weblogic.transaction.RollbackException: Unknown reason
    at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1818)
    at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:333)
    at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:227)
    at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:611)
    at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:57)
    at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(BaseRemoteObject.java:431)
    at com.thunderhead.simple.SimpleBean_t2toec_SimpleRemoteImpl.process(SimpleBean_t2toec_SimpleRemoteImpl.java:75)
    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:597)
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:64)
    at $Proxy300.process(Unknown Source)
    at com.thunderhead.weblogic.StartupService.postStart(Unknown Source)
    at weblogic.application.internal.flow.BaseLifecycleFlow$PostStartAction.run(BaseLifecycleFlow.java:292)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.application.internal.flow.BaseLifecycleFlow$LifecycleListenerAction.invoke(BaseLifecycleFlow.java:194)
    at weblogic.application.internal.flow.BaseLifecycleFlow.postStart(BaseLifecycleFlow.java:66)
    at weblogic.application.internal.flow.TailLifecycleFlow.activate(TailLifecycleFlow.java:33)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:16)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:140)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:106)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:820)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1227)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:436)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:67)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:517)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    .>
    <24-Jan-2008 11:01:34 o'clock GMT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1201172492513' for task '35'. Error is: 'javax.ejb.EJBException: nested exception is: weblogic.transaction.internal.AppSetRollbackOnlyException'
    javax.ejb.EJBException: nested exception is: weblogic.transaction.internal.AppSetRollbackOnlyException
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:79)
    at $Proxy300.process(Unknown Source)
    at com.thunderhead.weblogic.StartupService.postStart(Unknown Source)
    at weblogic.application.internal.flow.BaseLifecycleFlow$PostStartAction.run(BaseLifecycleFlow.java:292)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    Truncated. see log file for complete stacktrace
    javax.ejb.EJBException: nested exception is: weblogic.transaction.internal.AppSetRollbackOnlyException
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:79)
    at $Proxy300.process(Unknown Source)
    at com.thunderhead.weblogic.StartupService.postStart(Unknown Source)
    at weblogic.application.internal.flow.BaseLifecycleFlow$PostStartAction.run(BaseLifecycleFlow.java:292)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    Truncated. see log file for complete stacktrace
    This is on 10.3 Technology Preview

    Hi Tyson,
    Are you sure there are no other rows that have a conflicting value for the unique constraint? What you have described should work. Since the rows have been deleted, they are no longer considered when evaluating the constraints when executing RefreshTable. You should be able to both merge and refresh the workspace after deleting the rows. Also, the row(s) with the 'D' wm_optype would not have a retiretime value, unless the row was reinserted. Only the 'I' or 'U' row(s) would have a retiretime value in this case.
    If there are not any other rows, then I would need a more complete description. Are there any continuously refreshed workspaces that have T-520575 as a parent workspace? Those workspaces would also have to be checked.
    Regards,
    Ben

  • Catching unique constraint voilation at the VO level

    I have a Result table which is used as Result table/ for updation/ for insertion of new row.
    The underlying db table on which the Eo and consequently VO are based has a unique constraint which I want to catch and throw a suitable exception when the user is trying to update or insert using the result table which in my case is an advanced table. I am unable to figure out at what place I need to put the check. Though I am trying to handle the said condition before calling the getTransaction().commit(), I guess the DB is throwing the error even earlier which I presume is at the point of insertion into the Db which I guess happens at the EO setAttribute Level. So is it right to put the check at the setters in the EO???
    Kindly provide feedback as how to overcome this problem

    GFMIS.PK_ELTRADERID
    ON (lct.trader = exl.trader)Your ON clause should be work on the same column of your PK, that should be enough to avoid the unique constraint violation.
    Nicolas.

  • ORA-00001: unique constraint (REMEDY.SYS_C001727

    Hi: I have a simple table with a primary key (ENTRYID). All other fields are just fields with no constraints. When I try to insert records, for some records I get the above error. The table does not already have this record.
    INSERT INTO REMEDY.VITALEXCEPTION (ENTRYID, CUSTID, DEVICENAME, INTERFACE, EXCEPTION, DURATION, TIME)
    VALUES ('jvis2rspm01.S0/0/0_FMS:65999591 NA:3836400887 TERM:cmny83bbf/20351BDU1182798445', 'fxms', 'jvis2rspm01', 'S0/0/0_FMS:65999591 NA:3836400887 TERM:cmny83bbf/20351', 'BDU', 5476, 1182792934);
    INSERT INTO REMEDY.VITALEXCEPTION (ENTRYID, CUSTID, DEVICENAME, INTERFACE, EXCEPTION, DURATION, TIME)
    ERROR at line 1:
    ORA-00001: unique constraint (REMEDY.SYS_C001727) violated
    Could someone help.
    Thanks
    Ray

    hi,
    can you post the table structure?
    I suspect that ENTRYID has lesser length than the actual value and in effect the value has been truncated for some reason.
    The primary key value is too long, maybe creating a surrogate key would help.
    J

  • ORA-00001 - Unique Constraint on R5TRANSLINES

    Hello,
    I get the following error when i am inserting into R5TRANSLINES "2009-06-23 14:44:51,698 DEBUG [com.dstm.mp.MPDBException] **!!Error Code:|1|, Msg:|ORA-00001: unique constraint (REMPLOY.R5PRIK_TRL) violated"
    I have a flex trigger in the system which is envoked when inserting parts into my warehouse:
    Declare
    cursor c_palletparts( pallet varchar2) is
    select obj_part from r5objects
    where
    obj_parent = pallet;
    v_pallet varchar2(255);
    v_evtcode varchar2(255);
    v_transcode varchar2(255);
    v_line number :=0;
    v_store varchar2(255);
    v_trltype varchar2(4);
    v_trlrtype varchar2(4);
    v_trlio number;
    v_bin VARCHAR2(15);
    v_binin VARCHAR2(15);
    ncounter number;
    cur_message varchar2(200);
    begin
    select trl_part, trl_trans, trl_line into v_pallet, v_transcode, v_line from r5translines
    where rowid = :rowid;
    select count(*) into ncounter from r5objects where obj_code = v_pallet and obj_class = 'PALLET';
    if ncounter = 1 then
    select trl_part, trl_trans, trl_line, trl_store, trl_type, trl_rtype, trl_io, trl_bin into v_pallet, v_transcode, v_line, v_store, v_trltype, v_trlrtype, v_trlio, v_binin
    from r5translines
    where trl_trans = v_transcode
    and trl_line = v_line;
    IF v_trlrtype = 'RECV' THEN
    update r5objects set obj_store = v_store where obj_code = v_pallet;
    UPDATE R5PROPERTYVALUES SET PRV_VALUE = v_store WHERE prv_code = v_pallet||'#*' AND PRV_PROPERTY = 'RMP231' AND PRV_RENTITY = 'OBJ';
    END IF;
    -- update r5parts set par_byasset = '+' where par_code = v_pallet;
    for r_palletparts in c_palletparts(v_pallet) loop
    IF v_trlrtype = 'I' then
    select count(*) into ncounter from r5stock
    where sto_part = r_palletparts.obj_part
    and sto_store = v_store
    and sto_part_org = '*';
    IF ncounter = 0 then
    INSERT INTO R5STOCK (STO_PART, STO_STORE, STO_STOCKTAKE, STO_QTY, STO_CONSIGNMENT, STO_PART_ORG, STO_PRICETYPE, STO_ONDEMAND, STO_REPAIRQTY, STO_VENDORQTY, STO_SHOPQTY, STO_REPAIRTYPE, STO_REPSTOCKMETHOD, STO_REPAUTOASSIGN, STO_LABELDEFAULT)
    VALUES (r_palletparts.obj_part, v_store, SYSDATE, 1, '-', '*', 'A', '-', 0, 0, 0, '-', '-', '-', 0);
    END IF;
    select count(*) into ncounter from r5binstock
    where bis_part = r_palletparts.obj_part
    and bis_store = v_store
    and bis_part_org = '*';
    IF ncounter = 0 then
    INSERT INTO R5BINSTOCK(BIS_PART, BIS_STORE, BIS_BIN, BIS_LOT, BIS_QTY, BIS_PART_ORG, BIS_REPAIRQTY)
    VALUES (r_palletparts.obj_part, v_store, '*', '*', 1, '*', 0);
    END IF;
    select min(bis_bin) into v_bin from r5binstock
    where bis_part = r_palletparts.obj_part
    and bis_store = v_store
    and bis_part_org = '*';
    update r5binstock set bis_qty = 1 where bis_part = r_palletparts.obj_part
    and bis_store = v_store
    and bis_bin = v_bin;
    else
    update r5objects set obj_store = v_store where obj_code = r_palletparts.obj_part;
    -- UPDATE R5PROPERTYVALUES SET PRV_VALUE = v_store WHERE prv_code = r_palletparts.obj_part||'#*' AND PRV_PROPERTY = 'RMP231' AND PRV_RENTITY = 'OBJ';
    IF r_palletparts.obj_part NOT IN ('X') THEN
    cur_message := r_palletparts.obj_part||'|'||v_trltype||'|'||v_store||'|'||ncounter;
    -- raise_application_error(-20000,cur_message);
    END IF;
    v_bin := v_binin;
    end if;
    v_line := v_line + 1;
    insert into r5translines
    (trl_trans,trl_type, trl_rtype, trl_line, trl_date,
    trl_part, trl_lot, trl_bin, trl_store, trl_price,
    trl_qty, trl_io, trl_part_org)
    values
    (v_transcode, v_trltype, v_trlrtype, v_line, sysdate,
    r_palletparts.obj_part, '*', v_bin, v_store, 0,
    1, v_trlio, '*' );
    end loop;
    end if;
    Exception
    when no_data_found then
    Null;
    end;
    Can someone please tell me how to make this key unique.
    Many Thanks
    Chris

    Hi,
    You can create rule for truncate using below:
    BEGIN
    DBMS_RULE_ADM.CREATE_RULE(
    rule_name => 'TRUNCATE_RULE',
    condition => '(:ddl.get_object_owner() = ''HR'' AND ' ||
    ':ddl.get_object_name() = ''TEST'') AND ' ||
    ':ddl.get_command_type() = ''TRUNCATE TABLE'' ');
    END;
    Thanks,
    Reena

  • Unique constraint violation while updating a non PK column

    Hi,
    I seem to have found this strange error.
    What I try to do is bulk fetch a cursor in some table arrays. with limit of 1000
    Then using a forall and a save exceptions at the end
    I update a table with the values inside one of the table arrays.
    The column I update is not part of a PK
    I catch the error message: ORA-24381
    by using PRAGMA exception_init(dml_errors, -24381);
    and later on :
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    FOR i IN 1..sql%BULK_EXCEPTIONS.count LOOP
    lr_logging.parameters:= 'index = ' || sql%BULK_EXCEPTIONS(i).error_index || 'error = ' ||Sqlerrm(-sql%BULK_EXCEPTIONS(i).error_code) ;
    END LOOP;
    I insert these errors in another table. and i get 956 errors
    first one is :
    index = 3error = ORA-00001: unique constraint (.) violated
    last one is
    index = 1000error = ORA-00001: unique constraint (.) violated
    How can this be.Since i don't update in a PKcolumn.
    FULL CODE IS:
    PROCEDURE Update_corr_values( as_checkdate_from IN VARCHAR2,
    as_checkdate_until IN VARCHAR2,
    as_market IN VARCHAR2
    IS
    LS_MODULE_NAME CONSTANT VARCHAR2(30) := 'update_values';
    lr_logging recon_logging.logrec;
    CURSOR lc_update IS
    SELECT /*+ORDERED*/c.rowid,c.ralve_record_id,d.value,c.timestamp,f.value
    FROM rcx_allocated_values a,
    rcx_allocated_values b,
    meter_histories e,
    rcx_allocated_lp_value c,
    rcx_allocated_lp_value d,
    counter_values f
    WHERE a.slp_type NOT IN ('S89', 'S88', 'S10', 'S30') --AELP
    AND b.slp_type IN ('S89', 'S88') --residu
    AND a.valid_from >= to_date(as_checkdate_from,'DDMMYYYY HH24:MI')
    AND a.valid_to <= to_date(as_checkdate_until,'DDMMYYYY HH24:MI')
    AND a.market = as_market
    AND a.market = b.market
    AND a.ean_sup = b.ean_sup
    AND a.ean_br = b.ean_br
    AND a.ean_gos = b.ean_gos
    AND a.ean_dgo = b.ean_dgo
    AND a.direction = b.direction
    AND a.valid_from = b.valid_from
    AND a.valid_to = b.valid_to
    AND c.ralve_record_id = a.record_id
    AND d.ralve_record_id = b.record_id
    AND c.TIMESTAMP = d.TIMESTAMP
    AND e.ASSET_ID = 'KCF.SLP.' || a.SLP_TYPE
    --AND f.timestamp between to_date(gs_checkdate_from,'ddmmyyyy') and to_Date(as_checkdate_until,'ddmmyyyy')
    AND e.SEQ = f.MHY_SEQ
    AND f.TIMESTAMP =c.timestamp - 1/24
    ORDER BY c.rowid;
    TYPE t_value IS TABLE OF RCX_ALLOCATED_LP_VALUE.VALUE%TYPE;
    TYPE t_kcf IS TABLE OF COUNTER_VALUES.VALUE%TYPE;
    TYPE t_timestamp IS TABLE OF RCX_ALLOCATED_LP_VALUE.TIMESTAMP%TYPE;
    TYPE t_ralverecord_id IS TABLE OF RCX_ALLOCATED_LP_VALUE.RALVE_RECORD_ID%TYPE;
    TYPE t_row IS TABLE OF UROWID;
    ln_row t_row :=t_row();
    lt_value t_value := t_Value();
    lt_kcf t_kcf := t_kcf();
    lt_timestamp t_timestamp := t_timestamp();
    lt_ralve t_ralverecord_id := t_ralverecord_id();
    v_bulk NUMBER := 1000;
    val number;
    kcf number;
    ralve number;
    times date;
    dml_errors EXCEPTION;
    errors NUMBER;
    PRAGMA exception_init(dml_errors, -24381);
    BEGIN
    --setting arguments for the logging record
    lr_logging.module := LS_MODULE_NAME;
    lr_logging.context := 'INFLOW_ALL_VALUES_PARTS';
    lr_logging.logged_by := USER;
    lr_logging.parameters := 'Date time started: ' || TO_CHAR(sysdate,'DD/MM/YYYY HH24:MI');
    -- log debugs
    recon_logging.set_logging_env (TRUE, TRUE);
    recon_logging.log_event(lr_logging,'D');
    OPEN lc_update;
    LOOP
    FETCH lc_update BULK COLLECT INTO ln_row,lt_ralve,lt_value,lt_timestamp,lt_kcf LIMIT v_bulk;
    FORALL i IN NVL(lt_value.first,1)..NVL(lt_value.last,0) SAVE EXCEPTIONS
    UPDATE RCX_ALLOCATED_LP_VALUE
    SET VALUE = VALUE * lt_value(i) * lt_kcf(i)
    WHERE rowid =ln_row(i);
    COMMIT;
    lt_value.delete;
    lt_timestamp.delete;
    lt_ralve.delete;
    lt_kcf.delete;
    ln_row.delete;
    EXIT WHEN lc_update%NOTFOUND;
    END LOOP;
    CLOSE lc_update;
    recon_logging.log_event(lr_logging,'D');
    lr_logging.parameters := 'Date time ended: ' || TO_CHAR(sysdate,'DD/MM/YYYY HH24:MI');
    recon_logging.log_event(lr_logging,'D');
    --to be sure
    COMMIT;
    EXCEPTION
    WHEN dml_errors THEN
    recon_logging.set_logging_env(TRUE,TRUE);
    lr_logging.module := 'updatevalues';
    lr_logging.context := 'exception';
    lr_logging.logged_by := USER;
    lr_logging.parameters := 'in dml_errors';
    recon_logging.log_event(lr_logging);
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    lr_logging.parameters:=errors;
    recon_logging.log_event(lr_logging);
    lr_logging.parameters :=('Number of errors is ' || errors);
    --DBMS_OUTPUT.PUT_LINE('Number of errors is ' || errors);
    FOR i IN 1..sql%BULK_EXCEPTIONS.count LOOP
    lr_logging.parameters:= 'index = ' || sql%BULK_EXCEPTIONS(i).error_index || 'error = ' ||Sqlerrm(-sql%BULK_EXCEPTIONS(i).error_code) ;
    recon_logging.log_event(lr_logging);
    END LOOP;
    --recon_logging.set_logging_env(TRUE,TRUE);
    --recon_logging.log_event(lr_logging);
    commit;
    WHEN OTHERS THEN
    lr_logging.module := 'updatevalues';
    lr_logging.context := 'exception';
    lr_logging.logged_by := USER;
    recon_logging.set_logging_env(TRUE,TRUE);
    lr_logging.parameters := 'in others error=' || SQLERRM;
    recon_logging.log_event(lr_logging);
    commit;--to look which is truly the last (else only commit after 1000)
    --raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END Update_corr_values;

    Hi,
    No I didn't update a unique constraint.
    But I found out that there is a trigger that causes the unique constraint while updating in the table.
    Silly mistake.Didn't know there was a trigger there.
    Thx anyway.
    Greetz

Maybe you are looking for