Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Posts
    227

    Unanswered: Can I change ORA-00001:unique constraint...?

    hi,
    I've table ST
    NAME.........VARCHAR2(20)........PRIMARY KEY
    ID..............NUMBER

    INSERT INTO ST VALUES('PTS', 2);
    INSERT INTO ST VALUES('PTS', 2);

    I get (correctly) error ORA-00001:unique constraint (X_PK_Y) violated.

    Can I change this message of error??

    For example, can I get this error when I insert 2 primary key:

    wrong: change your value please!



    Thanks
    Raf

  2. #2
    Join Date
    Oct 2003
    Posts
    87

    Re: Can I change ORA-00001:unique constraint...?

    Just trap the message immediately after the attempt, and display the message you prefer, like "change your value please!" However, NAME is a very poor choice for a Primary Key!

    Originally posted by raf
    hi,
    I've table ST
    NAME.........VARCHAR2(20)........PRIMARY KEY
    ID..............NUMBER

    INSERT INTO ST VALUES('PTS', 2);
    INSERT INTO ST VALUES('PTS', 2);

    I get (correctly) error ORA-00001:unique constraint (X_PK_Y) violated.

    Can I change this message of error??

    For example, can I get this error when I insert 2 primary key:

    wrong: change your value please!



    Thanks
    Raf
    Oracle - DB2 - MS Access -

  3. #3
    Join Date
    Nov 2003
    Location
    Rotterdam, Netherlands
    Posts
    127
    If its within the pl/sql block, then you handle it in EXCEPTIONS

    WHEN *****

  4. #4
    Join Date
    Nov 2003
    Location
    Bangalore, INDIA
    Posts
    333

    Thumbs up

    Hi,

    you have defined a wrong constraint on ur table. Keep the ID as primary key. There can be 2 persons with the same name. In this case ur constraint will show errors.
    SATHISH .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •