Home » SQL & PL/SQL » SQL & PL/SQL » DUP_VAL_ON_INDEX (Which Index ?)
DUP_VAL_ON_INDEX (Which Index ?) [message #279638] Fri, 09 November 2007 08:15 Go to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
I have a table with several unique constraints, I am trapping when DUP_VAL_ON_INDEX in my exception clause.

Is there an easy way to know which constraint has been violated to give the user a relevant error message ?
Re: DUP_VAL_ON_INDEX (Which Index ?) [message #279639 is a reply to message #279638] Fri, 09 November 2007 08:23 Go to previous messageGo to next message
pablolee
Messages: 2836
Registered: May 2007
Location: Scotland
Senior Member
I would suggest parsing the constraint name from sqlerrm.
Re: DUP_VAL_ON_INDEX (Which Index ?) [message #279642 is a reply to message #279638] Fri, 09 November 2007 08:39 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you just want to return an error message to user then don't trap the error let it go.

Regards
Michel
Re: DUP_VAL_ON_INDEX (Which Index ?) [message #279675 is a reply to message #279638] Fri, 09 November 2007 09:56 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
I wanted a pretty error message :}
Re: DUP_VAL_ON_INDEX (Which Index ?) [message #279676 is a reply to message #279639] Fri, 09 November 2007 09:57 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
pablolee wrote on Fri, 09 November 2007 08:23

I would suggest parsing the constraint name from sqlerrm.



Of course!! Not enough caffeine yet
Re: DUP_VAL_ON_INDEX (Which Index ?) [message #279772 is a reply to message #279675] Sat, 10 November 2007 03:40 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
But you lose the line number where the error raised.
Better create your pretty error message in the caller.

Regards
Michel
Previous Topic: order by in sql statement
Next Topic: Need logic for row1 - row2
Goto Forum:
  


Current Time: Sat Dec 10 08:51:40 CST 2016

Total time taken to generate the page: 0.07835 seconds