Solved

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

Posted on 2016-09-22
4
74 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
4 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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 31

Expert Comment

by:awking00
Comment Utility
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 34

Accepted Solution

by:
Mark Geerlings earned 500 total points
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ORACLE SQL DEVELOPER Query ? 5 58
Need help with Oracle syntax 4 39
File generation using utl_file 4 28
automatic email alert 1 20
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now