ORA-00001: Unique constraint (OWNER.CONSTRAINT_NAME) violated
The constraint indicated in the error message is a unique or primary key on a table.
An attempt was made to insert a record with a key that already exists in that table. This is not allowed and thus violates the constraint.
you can use following statement to identify the columns of the table this constraint is based upon:
select table_name, column_name
from all_cons_columns
where owner='<Here OWNER>'
and constraint_name='<Here CONSTRAINT_NAME>'
order by position;
Welcome to our forum for Oracle error: ORA-00001 Add your own message
I can insert data into the table. No problem.
When I try to login by using one field of the table.the following error occurred.
service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
javax.servlet.ServletException: ORA-00001: unique constraint (TIC.SYS_C0010331) violated
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
Check on what table the contraint is defined:
select table_name, column_name
from all_cons_columns
where owner='TIC'
and constraint_name='SYS_C0010331'
order by position;
ORA-00001:unique contraint (ADMIN.BELM_PK) violated.
Is this a normal response?
The data already exists in the tables. A primary key constraint prevents duplicates from being created.
You are violating a unique check constraint, use different data when testing you procedure
But while running through C++ code which calls this procedure error is thrown while running command.
If so, you can check on what column(s) the unique constraint is set and check if something is called twice in your C++ code.
eg. twice the execute call for the procedure
But the procedure is writen in that why if the recored is already present in the table then it will update the records else it will insert.
With my data there is no record in table with matching data so it is inserting in the table and failing in insert.
After you make a connection, issue following statement.
alter session set events '10046 trace name context forever, level 12';
After you receive the error, check the user_dump_dest for trace files and have a look why it is failing.
and the message get out to me when i press button
what is the solution?
This can lead to errors, and you should find a more safe way. This is probably the case with your procedure.
Hi all guru's, i got a doubt that cant be answered here... i need to update a table in a procedure but unexpectedly it cant be done... hre are the code:
[code]
cursor c14 is
select a.contact_name, b.scr_name v_name, b.emplid
from PS_TEST a, PS_TAKE b where b.emplid = a.emplid
for update of a.contact_name;
--------------------------------------------
for rec in c014 loop
select scr_last_name v_mname1, scr_middle_name v_lname1, scr_first_name v_fname1
, (scr_first_name ||' '||scr_last_name||' '||scr_middle_name) v_name1
into v_mname1, v_lname1, v_fname1, v_name1
from PS_TAKE sample(1) where rownum = 1 ;
update
PS_TEST
set contact_name = v_name1
--where contact_name = rec.contact_name;
where current of c014;
exit when c014%notfound;
end loop;
[/code]
Above are the cursor and the code that related. This code cant be done in procedure, it ill show this error :
[code]
ERROR at line 1:
ORA-00001: unique constraint (SYSADM.PS_TEST) violated
ORA-06512: at "SHAHRIL.UPDATE_ALL_DEPENDENTS", line 572
ORA-06512: at line 1
[/code]
Kindly need all of your sggestion and opinion on this. An advance, really appreciate on it.
Thanks
Hi all guru's, i got a doubt that cant be answered here... i need to update a table in a procedure but unexpectedly it cant be done... hre are the code:
[code]
cursor c14 is
select a.contact_name, b.scr_name v_name, b.emplid
from PS_TEST a, PS_TAKE b where b.emplid = a.emplid
for update of a.contact_name;
--------------------------------------------
for rec in c014 loop
select scr_last_name v_mname1, scr_middle_name v_lname1, scr_first_name v_fname1
, (scr_first_name ||' '||scr_last_name||' '||scr_middle_name) v_name1
into v_mname1, v_lname1, v_fname1, v_name1
from PS_TAKE sample(1) where rownum = 1 ;
update
PS_TEST
set contact_name = v_name1
--where contact_name = rec.contact_name;
where current of c014;
exit when c014%notfound;
end loop;
[/code]
Above are the cursor and the code that related. This code cant be done in procedure, it ill show this error :
[code]
ERROR at line 1:
ORA-00001: unique constraint (SYSADM.PS_TEST) violated
ORA-06512: at "SHAHRIL.UPDATE_ALL_DEPENDENTS", line 572
ORA-06512: at line 1
[/code]
Kindly need all of your sggestion and opinion on this. An advance, really appreciate on it.
Thanks
hello ORA-00001: Unique constraint (OWNER.CONSTRAINT_NAME) violated, this is the error occuring while am trying to insert the records into the table could u please provide a solution for this error
You are inserting a value into a column for which the same value already exists.
You can use the query above to see what column(s) the constraint is defined upon.
Hello, I hope someone can help with this -
We have a table that has a unique key on one of the columns, but that column is also allowed to be null. The intent of this was that any number of records could be null in that column, but any records that DID have values should all have unique values for that column. This is exactly how a unique key is supposed to work, as I understand it.
This has been working perfectly fine for years and has not been changed at all. However, recently our database has begun to throw this error when a stored procedure tries to insert a record that would have null in that column, and I can't figure out why.
Sample table and constraint scripts (names altered and extra stuff dropped to protect the innocent ^_^):
create table ABC.ITEM_MASTER
( item_id number(8),
item_name varchar2(12),
bucket_code varchar2(4)
);
create unique index ABC.ITEM_MASTER_UC1 on ABC.ITEM_MASTER (bucket_code);
Stored proc code that is causing the error:
insert into ABC.ITEM_MASTER (item_id, item_name) values (123,'A');
Error message:
ORA-00001: unique constraint (ABC.ITEM_MASTER_UC1) violated
...Help, please?
Can it be that someone (accidentally) defined a default value on the bucket_code column, so that everytime a Null value is inserted, an actual value (the default) is used?
Unfortunately, no. I have just now re-checked the table, and there is definitely no default value on the bucket_code column.
Thanks for your attention; this problem has stumped our DBAs too, we are temporarily working around this by disabling the constraint, but are hoping to find some way to get it working properly again.
It might also be a bug in Oracle you encounter. Did you recently install CPU patches, or upgrade the database?
You can try to trace the session and see what happens.
See: http://www.dbmotive.com/oracle_howto.php?howto=24
alter session set events '10046 trace name context forever, level 12';
If this does not reveal anything, you can choose to dump extra info when the event occurs:
alter system set events '1 trace name errorstack level 3';
This will dump some interesting info in a trace file in user_dump_dest when you receive ORA-00001
To switch off you need to:
alter system set events '1 trace name context off';
Thanks, due to segregation of duties I can't try this myself, but I have passed on all this info to our DBAs and they think it is a good idea. They will try it.
Thank you again!
Add your message
If you need more information about this particular error message, you can leave a forum message.
We are replying to this message whenever we have some spare time, so please do not consider this as a private 'solve my critical issue asap' service.
Should you need professional Oracle Assistance to make your project a success, please have a look at our consultancy services.
In order to prevent automatic generation of messages, we are asking for a validation code. This code is unique and is generated every time a new message is asked.
If you do not enter the validation correctly, your message will not be recorded.
