Unique constraint under hibernate

Hello,
I'm trying to run a java junit test in Eclipse.
The test first inserts a few rows in different tables.
But it gives an exception with an Oracle message.
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
     at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
     at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
     at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
     at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
     at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
     at com.ericsson.pii.dataaccessor.AccessDaoHibernateImplSpringTest.testAggregateSingleAccesses(AccessDaoHibernateImplSpringTest.java:74)
     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 junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (PIIUSER_JUNIT.SYS_C009305) violated
     at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:342)
     at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
     at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
     at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
     at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
     ... 24 more
Here is the test source code:
          Transaction transaction = session.beginTransaction();
          Document d1 = ObjectMother.createSimpleDocument("d1", "a", "EN", documentDao);
          Document d2 = ObjectMother.createSimpleDocument("d2", "a", "EN", documentDao);
          ObjectMother.createAccess(accessDao, d1, DateUtil.createOneSpecificDay(2006, Calendar.AUGUST, 4, 10, 0, 0).getTime());
          ObjectMother.createAccess(accessDao, d1, DateUtil.createOneSpecificDay(2006, Calendar.AUGUST, 4, 10, 10, 0).getTime());
          ObjectMother.createAccess(accessDao, d1, DateUtil.createOneSpecificDay(2006, Calendar.AUGUST, 5, 10, 10, 0).getTime());
          ObjectMother.createAccess(accessDao, d2, DateUtil.createOneSpecificDay(2006, Calendar.AUGUST, 5, 10, 10, 0).getTime());
          ObjectMother.createAccess(accessDao, d2, DateUtil.createOneSpecificDay(2006, Calendar.AUGUST, 6, 10, 10, 0).getTime());
          transaction.commit();
The exception message points to the transaction.commit();
line.
I'm in the dark and my search light is dying on me..
Stephane

And here is the verbose output in the Eclipse console:
16:06:38,560 ERROR SchemaExport:272 - Unsuccessful: create table document (id number(19,0) not null, title varchar2(255 char), updateDate timestamp, archive varchar2(255 char), channel varchar2(255 char), documentNumber varchar2(255 char), revision varchar2(255 char), language varchar2(255 char), format varchar2(255 char), informationType varchar2(255 char), preparedBy varchar2(255 char), securityClass varchar2(255 char), sizeInBytes number(19,0), category varchar2(255 char), createDate timestamp, deleteDate timestamp, test number(1,0), accessClass varchar2(255 char), in1095 number(1,0), inDocNumber number(1,0), inDocPlan number(1,0), inFind number(1,0), piiAddDate timestamp, accesses30days number(10,0), documentUrl varchar2(255 char), accessesToTime timestamp, primary key (id))
16:06:38,563 ERROR SchemaExport:273 - ORA-00955: name is already used by an existing object
16:06:39,041 ERROR SchemaExport:272 - Unsuccessful: create table usage (id number(19,0) not null, document_id number(19,0), fromTime timestamp, toTime timestamp, type varchar2(255 char), count number(10,0), primary key (id))
16:06:39,042 ERROR SchemaExport:273 - ORA-00955: name is already used by an existing object
16:06:39,067 ERROR SchemaExport:272 - Unsuccessful: create index doc_no_rev_lang_index on document (documentNumber, revision, language)
16:06:39,068 ERROR SchemaExport:273 - ORA-00955: name is already used by an existing object
16:06:39,185 ERROR SchemaExport:272 - Unsuccessful: create index prevent_duplicates on usage (document_id)
16:06:39,186 ERROR SchemaExport:273 - ORA-00054: resource busy and acquire with NOWAIT specified
16:06:39,189 ERROR SchemaExport:272 - Unsuccessful: alter table usage add constraint FK6A67DA17CED002B foreign key (document_id) references document
16:06:39,189 ERROR SchemaExport:273 - ORA-02275: such a referential constraint already exists in the table
Hibernate: select relationty0_.id as id4_, relationty0_.name as name4_, relationty0_.distance as distance4_ from relation_type relationty0_
Hibernate: insert into relation_type (name, distance, id) values (?, ?, ?)
Hibernate: insert into relation_type (name, distance, id) values (?, ?, ?)
Hibernate: insert into relation_type (name, distance, id) values (?, ?, ?)
Hibernate: insert into relation_type (name, distance, id) values (?, ?, ?)
Hibernate: insert into relation_type (name, distance, id) values (?, ?, ?)
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into document (title, updateDate, archive, channel, documentNumber, revision, language, format, informationType, preparedBy, securityClass, sizeInBytes, category, createDate, deleteDate, test, accessClass, in1095, inDocNumber, inDocPlan, inFind, piiAddDate, accesses30days, documentUrl, accessesToTime, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:06:39,843 WARN JDBCExceptionReporter:71 - SQL Error: 1, SQLState: 23000
16:06:39,844 ERROR JDBCExceptionReporter:72 - ORA-00001: unique constraint (PIIUSER_JUNIT.SYS_C009305) violated
16:06:39,844 WARN JDBCExceptionReporter:71 - SQL Error: 1, SQLState: 23000
16:06:39,845 ERROR JDBCExceptionReporter:72 - ORA-00001: unique constraint (PIIUSER_JUNIT.SYS_C009305) violated
16:06:39,847 ERROR AbstractFlushingEventListener:300 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
     at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
     at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
     at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
     at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
     at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
     at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
     at com.ericsson.pii.dataaccessor.AccessDaoHibernateImplSpringTest.testAggregateSingleAccesses(AccessDaoHibernateImplSpringTest.java:74)
     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 junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (PIIUSER_JUNIT.SYS_C009305) violated
     at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:342)
     at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
     at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
     at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
     at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
     ... 24 more

Similar Messages

  • UNIQUE constraint but with a condition?

    Hi!
    Is it possible to define a unique constraint in a table which would apply only under a condition (depending on row content only) ?
    For example:
    CREATE TABLE example
      pk number,
      a number,
      b number,
      c VARCHAR2(10),
      x number
    The constraint would be UNIQUIE (a,b), but only when x is > 10.
    So if x is not above 10, then same values for a nd b should be allowed.
    Maybe with a view ?
    Like this?
    create view example_view  ( unique (a,b)) AS
    select a,b from example where x > 10
    with read only; -- ??? needed? Regards,
    David

    Hello David,
    not on the table directly, but you can define a Materialized View with your condition
    CREATE MATERIALIZED VIEW check_example
       BUILD IMMEDIATE
       REFRESH FAST ON COMMIT
       AS SELECT a,b
       FROM example
       WHERE x > 10On this MV you can define your unique constraint. The refresh will fail if the condition is not met and you will get an error for your changes in the example table..
    Regards
    Marcus

  • Getting "unique constraint" error while mapping customized jsp

    Hi,
    We are implementing iStore R12 (12.1.3).
    We have customized ibeCCtdMenu.jsp, renamed it as xxibeCCtdMenu.jsp and moved it to $OA_HTML/ folder.
    Now in template manager, we are creating a new source file (xxibeCCtdMenu.jsp) under "Menu generation template".
    However when we select site and language as "All", it gives following error:
    Error in saving logical to physical mapping
    ORA-00001: unique constraint (IBE.IBE_DSP_LGL_PHYS_MAP_U2) violated in Package IBE_PhysicalMap_GRP Procedure save_physicalmap
    All sites and all language exists already exists for deliverable 7670
    How can we overcome this error? Please advise.
    Thanks,
    Vivek

    for a given combination of Site and Language, only one template can exists.
    Default file provided by Oracle is set with combination as All Sites - All Languages, and you will not be able to change it.
    Register your file with combination such as All Sites - English Language
    or <specific site>, All language.
    Then it will work fine.
    Hrishikesh

  • Unique constraint violation - Finding inserted row before commit

    Hi,
      I have a scenario something like that, where I need to insert a row to a table - contact, for different employees under different department. So I happen to insert same employee contact multiple times & do commit at the last if there is no contact in the table. How to find out if the same employee record is already inserted ?.
    The unique constraints is on emp id + depatment id in the contact table. So I face the issue when i do the commit, it finds the same emp id + dept id contact has been inserted multiple times.
    Please let me know how to handle it?
    Regards,
    Dhamo.

    Hi
    What is exactly what you want to achieve? Do you want to display a message to the user? Do you want to prevent it to post the contact if it already exists?
    Regards

  • 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

  • Programatically detecting uniqueness constraint violations when using Direct Path API

    I'm developing an application that bulk loads data into the
    database using the DirectPath API.
    According to the DirectPath API documentation uniqueness
    constraints must be disabled prior to importing data using the
    DirectPath API, then the constraints must be re-enabled.
    If duplicate data is inserted when the constraints are disabled,
    enabling the constraints results in the constraint's underlying
    index being left in an "unusable" state.
    The SQL*Loader tool (which also uses the DirectPath API) somehow
    manages to deal with this.
    It can successfully detect which data causes the constraint
    violation, and politely writes the offending data to a bad rows
    file.
    If SQL*Loader also uses the DirectPath API - how does it detect
    which data causes a constraint violation.
    The mere fact that SQL*Loader can do this in DirectPath mode,
    shows that it is possible.
    Any ideas how to detect which data causes a constraint violation
    when using the DirectPath API ?
    - Andy

    I'm developing an application that bulk loads data into the
    database using the DirectPath API.
    According to the DirectPath API documentation uniqueness
    constraints must be disabled prior to importing data using the
    DirectPath API, then the constraints must be re-enabled.
    If duplicate data is inserted when the constraints are disabled,
    enabling the constraints results in the constraint's underlying
    index being left in an "unusable" state.
    The SQL*Loader tool (which also uses the DirectPath API) somehow
    manages to deal with this.
    It can successfully detect which data causes the constraint
    violation, and politely writes the offending data to a bad rows
    file.
    If SQL*Loader also uses the DirectPath API - how does it detect
    which data causes a constraint violation.
    The mere fact that SQL*Loader can do this in DirectPath mode,
    shows that it is possible.
    Any ideas how to detect which data causes a constraint violation
    when using the DirectPath API ?
    - Andy

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

  • Error while adding Image: ORA-00001: unique constraint

    Dear all,
    I have an error while adding images to MDM I can´t explain. I want to add 7231 images. About 6983 run fine. The rest throws this error.
    Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
    Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
    Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
    Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
    Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
    Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
    Name=CodeName; Type=2; Value=207603_Img8078_gif; ArraySize=0; NullInd=0;
    Name=Name_L3; Type=2; Value=207603_Img8078.gif; ArraySize=0; NullInd=0;
    Error: Service 'SRM_MDM_CATALOG', Schema 'SRMMDMCATALOG2_m000', ERROR CODE=1 ||| ORA-00001: unique constraint (SRMMDMCATALOG2_M000.IDATA_6_DATAID) violated
    Last CMD: INSERT INTO A2i_Data_6 (PermanentId, DataId, DataGroupId, Description_L3, CodeName, Name_L3) VALUES (:1, :2, :3, :4, :5, :6)
    Name=PermanentId; Type=9; Value=1641157; ArraySize=0; NullInd=0;
    Name=DataId; Type=5; Value=426458; ArraySize=0; NullInd=0;
    Name=DataGroupId; Type=4; Value=9; ArraySize=0; NullInd=0;
    Name=Description_L3; Type=2; Value=; ArraySize=0; NullInd=0;
    Name=CodeName; Type=2; Value=207603_Img8085_gif; ArraySize=0; NullInd=0;
    Name=Name_L3; Type=2; Value=207603_Img8085.gif; ArraySize=0; NullInd=0;
    I checked all data. There is no such dataset in the database. Can anybody give me a hint how to avoid this error.
    One thing I wonder: The PermanentId is allways the same but I can´t do anything here.
    BR
    Roman
    Edited by: Roman Becker on Jan 13, 2009 12:59 AM

    Hi Ritam,
    For such issues, can you please create a new thread or directly email the author rather than dragging back up a very old thread, it is unlikely that the resolution would be the same as the database/application/etc releases would most probably be very different.
    For now I will close this thread as unanswered.
    SAP SRM Moderators.

  • Difference between unique constraint and unique index

    1. What is the difference between unique constraint and unique index when unique constraint is always indexed ? Which one is better in this case for better performance ?
    2. Is Composite index of 3 columns x,y,z better
    or having independent/ seperate indexes on 3 columns x,y,z is better for better performance ?
    3. It has been very confusing for me to decide which columns to index, I have indexed most foreignkey columns, is it a good idea ? We do lot of selects and DMLS on most of our tables. Is there any query that I can run and find out if indexes are really being used and if they are improving any performance. I have analyzed and computed my indexes using ANALYZE index index_name validate structure and COMPUTE STATISTICS;
    null

    1. Unique index is part of unique constraint. Of course you can create standalone unique index. But is is no point to skip the logical view of business if you spend same effort to achive.
    You create unique const. Oracle create the unique index for you. You may specify index characteristic in unique constraint.
    2. Depends. You can't utilize the composite index if the searching condition is not whole or front part of the indexing key. You can't utilize your index if you query the table for y=2. That is.
    3. As old words in database arena, Index may be good or bad for a table depending on the size of table, number of columns in the table... etc. It is very environmental dependent. In fact, It is part of database nomalization. Statistic is a way oracle use to determine the execution plan.
    Steve
    null

  • Difference Between Unique Index vs Unique Constraint

    Can you tell me
    what is the Difference Between Unique Index vs Unique Constraint.
    and
    Difference Between Unique Index and bitmap index.
    Edited by: Nilesh Hole,Pune, India on Aug 22, 2009 10:33 AM

    Nilesh Hole,Pune, India wrote:
    Can you tell me
    what is the Difference Between Unique Index vs Unique Constraint.http://www.jlcomp.demon.co.uk/faq/uk_idx_con.html
    and
    Difference Between Unique Index and bitmap index.The documentation is your friend:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#CNCPT1157
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref1008
    Regards,
    Rob.

  • Unique Index vs. Unique Constraint

    Hi All,
    I'm studying for the Oracle SQL Expert Certification. At one point in the book, while talking about indices, the author says that a unique index is not the same a unique constraint. However, he doesn't explain why they're two different things.
    Could anyone clarify the difference between the two, please?
    Thanks a lot,
    Valerio

    A constraint has different meaning to an index. It gives the optimiser more information and allows you to have foreign keys on the column, whereas a unique index doesn't.
    eg:
    SQL> create table t1 (col1 number, col2 varchar2(20), constraint t1_uq unique (col1));
    Table created.
    SQL> create table t2 (col1 number, col2 varchar2(20));
    Table created.
    SQL> create unique index t2_idx on t2 (col1);
    Index created.
    SQL> create table t3 (col1 number, col2 number, col3 varchar2(20), constraint t3_fk
      2                   foreign key (col2) references t1 (col1));
    Table created.
    SQL> create table t4 (col1 number, col2 number, col3 varchar2(20), constraint t4_fk
      2                   foreign key (col2) references t2 (col1));
                     foreign key (col2) references t2 (col1))
    ERROR at line 2:
    ORA-02270: no matching unique or primary key for this column-listIt's like saying "What's the difference between a car seat and an armchair? They both allow you to sit down!"

  • ORA-00001 - unique constraint violation when upgrading 10g EUL

    Hi,
    I am trying to upgrade my Discoverer 4i to Discoverer 10g.
    When I log into 10g, it prompts me to upgrade the EUL. After making the right back up of my 4i EUL, I continue with the upgrade.
    During the upgrade, I am hit with this error:
    Database error: ORA-00001 unique constraint (EUL_HRMS.EUL5_FOL_UK_1) violated.
    I understand that this happens when user tries to insert an already existing value into a column defined as unique. However, I am not sure on how to resolve it.
    Can anyone please advice.
    Thanks in advance!
    Regards,
    Harpreet Sidhu

    Hi Rod,
    I've run the queries and these are the results. Each query returned one row.
    1. SELECT FROM EUL_HRMS.EUL5_DOC_FOLDERS*
    FOL_ID     100057
    FOL_NAME     ROOT
    FOL_DEVELOPER_KEY     ROOT
    FOL_DESCRIPTION     
    FOL_EU_ID     100000
    FOL_PARENT_ID     
    FOL_USER_PROP2     
    FOL_USER_PROP1     
    FOL_ELEMENT_STATE     0
    FOL_CREATED_BY     EUL_HRMS
    FOL_CREATED_DATE     19-Jun-09
    FOL_UPDATED_BY     EUL_HRMS
    FOL_UPDATED_DATE     19-Jun-09
    NOTM     0
    2. SELECT EU_ID, EU_SECURITY_MODEL, EU_USE_PUB_PRIVS, EU_ROLE_FLAG
    FROM EUL_HRMS.EUL5_EUL_USERS
    WHERE EU_USERNAME = 'PUBLIC'
    EU_ID     3000
    EU_SECURITY_MODEL     0
    EU_USE_PUB_PRIVS     1
    EU_ROLE_FLAG     0
    Thanks!

  • ORA-00001: unique constraint

    Hi,
    I disabled the primary key of the table to which I insert the data like this :
    INSERT INTO TABLE_X
    select * from table_1 UNION ALL
    select * from table_2 ;
    but I receive this error :
    ORA-00001: unique constraint TABLE_X.PK violated
    Why ? It is already disabled.
    thank you.
    Message was edited by:
    user522961
    Message was edited by:
    user522961
    Message was edited by:
    user522961

    Is it possible you kept the index when disabling the primary key?
    YAS@11G>create table t as select object_id from all_objects where rownum<=10;
    Table created.
    YAS@11G>alter table t add constraint PK_T primary key(object_id);
    Table altered.
    YAS@11G>alter table t disable constraint pk_t;
    Table altered.
    YAS@11G>insert into t select * from t;
    10 rows created.
    YAS@11G>rollback;
    Rollback complete.
    YAS@11G>alter table t enable constraint pk_t;
    Table altered.
    YAS@11G>alter table t disable constraint pk_t keep index;
    Table altered.
    YAS@11G>insert into t select * from t;
    insert into t select * from t
    ERROR at line 1:
    ORA-00001: unique constraint (YAS.PK_T) violated

  • ORA-00001: unique constraint @ impdp with table_exists_action=truncate

    Hi everybody
    I can't understand why my data pump import execution with parameter TABLE_EXISTS_ACTION=TRUNCATE returned ORA-00001 (unique constraint violation), while importing schema tables from a remote database where the source tables have the same unique constraints as the corresponding ones on the target database.
    Now my question is "If the table would be truncated, why I get unique constraint violation when inserting records from a table where the same unique constraint is validated?
    Here are the used parameter file content and the impdp logfile.
    parfile
    {code}
    DIRECTORY=IMPEXP_LOG_COLL2
    CONTENT=DATA_ONLY
    NETWORK_LINK=PRODUCTION
    PARALLEL=1
    TABLE_EXISTS_ACTION=TRUNCATE
    EXCLUDE=STATISTICS
    {code}
    logfile
    {code}
    Import: Release 10.2.0.1.0 - Production on Gioved� 22 Ottobre, 2009 15:33:44
    Copyright (c) 2003, 2005, Oracle. All rights reserved.
    Connesso a: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    FLASHBACK automatically enabled to preserve database integrity.
    Starting "IMPEXP"."PROVA_REFRESH_DBCOLL": impexp/********@dbcoll SCHEMAS=test_pump LOGFILE=test_pump.log parfile=refresh_dbcoll.par JOB_NAME=prova_refresh_dbcoll
    Estimate in progress using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 523 MB
    ORA-31693: Table data object "TEST_PUMP"."X10000000_TRIGGER" failed to load/unload and is being skipped due to error:
    ORA-00001: unique constraint (TEST_PUMP.SYS_C00726627) violated
    ORA-31693: Table data object "TEST_PUMP"."X10000000_BASIC" failed to load/unload and is being skipped due to error:
    ORA-00001: unique constraint (TEST_PUMP.SYS_C00726625) violated
    Job "IMPEXP"."PROVA_REFRESH_DBCOLL" completed with 2 error(s) at 15:34:04
    {code}
    Thank you
    Bye Alessandro

    I forgot to read the last two lines of the documentation about TABLE_EXISTS_ACTION where it says:
    "TRUNCATE cannot be used on clustered tables or over network links."
    So it seems that it ignored the clause for the use of NETWORK_LINK and unreasonably opted for an APPEND action instead of throwing an error to highlight the conflicting parameters in the used configuration.
    Bye Alessandro

  • 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

Maybe you are looking for