Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot validate duplicate keys found

Pranav.shahJun 20 2015 — edited Jun 22 2015

i am trying to create Unique Constraint of table oms_product_group's Column product_group_name.

it's parent child relationship like parent_id will be same for some the product_group_name

Example:

product_group_name         parent_id

-----------------------------------------------

All                                           0

Mobile                                     1

Laptop                                    1

Men                                        2  

Men                                        2 (<--- if i have already created MEN then it must not allow me create it again)

Android                                   3

What i have tried.

alter table OMS_PRODUCT_GROUP add constraint OMS_PRODUCT_GROUP_NAME_UN unique (PRODUCT_GROUP_NAME) DEFERRABLE INITIALLY IMMEDIATE;

ERROR: ORA-02299: cannot validate (ECUBE.OMS_PRODUCT_GROUP_NAME_UN) - duplicate keys found

alter table OMS_PRODUCT_GROUP add novalidate constraint OMS_PRODUCT_GROUP_NAME_UN

      using index (create index unique_index on OMS_PRODUCT_GROUP(PRODUCT_GROUP_NAME));

ORA-02253: constraint specification not allowed here

So basically if some one inserted one value name he/she can not insert same value name again that's i am creating Unique Key Constraints.

Thank You

Pranav Shah.

This post has been answered by Stew Ashton on Jun 20 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 20 2015
Added on Jun 20 2015
20 comments
9,594 views