Solved

java.sql.SQLIntegrityConstraintViolationExc eption: ORA-00001: unique constraint

Posted on 2016-09-22
4
246 Views
Last Modified: 2016-10-06
Hi,

we are getting unique constraint ,Do we get this error while inserting same ID value into the table only or is there any other reason?
during update statement also also do we get this error?

org.springframework.dao.DuplicateKeyException:

### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationExc
eption: ORA-00001: unique constraint (TESTSANDBOX.SYS_C0040162) violated
 
### The error may involve alfresco.propval.parameter_IdPropertyRoot
### The error occurred while setting parameters
### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique
constraint (TESTSANDBOX.SYS_C0040162) violated
 
; SQL []; ORA-00001: unique constraint (TESTSANDBOX.SYS_C0040162) violated
; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-000
01: unique constraint (TESTSANDBOX.SYS_C0040162) violated
0
Comment
Question by:chaitu chaitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 41811898
Do we get this error while inserting same ID value into the table only or is there any other reason?

check the documentation below for more info:

Class SQLIntegrityConstraintViolationException
This indicates that an integrity constraint (foreign key, primary key or unique key) has been violated
https://docs.oracle.com/javase/7/docs/api/java/sql/SQLIntegrityConstraintViolationException.html

scroll down to Constructor Detail section for more info.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41812055
you get this when violation a unique index

any of the columns given by this query should indicate at what columns to look
(assuming you login with the schema owner TESTSANDBOX)

select ui.index_name, ui.table_name, uic.column_name 
from user_indexes ui, user_ind_columns uic
where ui.uniqueness = 'UNIQUE'
  and ui.index_name = uic.index_name
  and ui.table_name = uic.table_name
  and ui.table_name = 'your table'
order by 2, 1

Open in new window


or use the index_name
select ui.index_name, ui.table_name, uic.column_name 
from user_indexes ui, user_ind_columns uic
where ui.uniqueness = 'UNIQUE'
  and ui.index_name = uic.index_name
  and ui.table_name = uic.table_name
  and ui.index_name = 'SYS_C0040162'
order by 2, 1

Open in new window

0
 
LVL 32

Expert Comment

by:awking00
ID: 41812408
Can you post your update query and the output from the following query?
select uc.constraint_name, ucc.column_name, uc.constraint_type
from user_constraints uc, user_cons_columns ucc
where uc.table_name = ucc.table_name
and uc.constraint_name = ucc.constraint_name
and uc.table_name = 'YOURTABLE'
and uc.constraint_type in ('P','U','R');
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 500 total points
ID: 41818482
Yes, this error indicates that Oracle detected an attempt to violate the unique index that is associated with either a PRIMARY KEY or UNIQUE KEY constraint named: SYS_C0040162.  This constraint is owned by (that is, it is in the schema of):  TESTSANDBOX.

The second query from Geert Gruwez can be used to identify the table name.

Yes, the ORA-00001 error can happen either with an insert or an update, but it is more common with inserts (mainly because it is rare in most applications to try an update of a column value that is part of a PRIMARY KEY or UNIQUE KEY).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question