Unique Constraint Violation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • trinanjan
    New Member
    • Dec 2007
    • 1

    Unique Constraint Violation

    Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by trinanjan
    Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
    Hi Trinanjan,

    Welcome to TSDN!!

    Please make sure you follow POSTING GUIDELINES every time you post in this forum

    Thanks
    MODERATOR

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Originally posted by trinanjan
      Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
      Unique Constraint violation takes place when you try to insert a same value in a particular column that already exists.

      Check this:

      [code=oracle]
      SQL> create table abcd(a NUMBER UNIQUE);

      Table created.

      SQL> insert into abcd values(1);

      1 row created.

      SQL> /
      insert into abcd values(1)
      *
      ERROR at line 1:
      ORA-00001: unique constraint (APPS.SYS_C0015 7910) violated


      SQL> ed
      Wrote file afiedt.buf

      1* insert into abcd values(NULL)
      SQL> /

      1 row created.

      SQL> /

      1 row created.

      SQL> /

      1 row created.

      SQL>

      [/code]

      Any number of NULLS can be inserted but not the same value.

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Originally posted by trinanjan
        Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
        It occurs to maintain data integrity .
        To solve this u need to check for existance of data in a unique / Primay key field before inserting or updating the records.

        Comment

        Working...