Jes wrote:
>
Quote:
Originally Posted by
Is there any way to construct a more meaningful error description so
that it can be displayed to the user
>
Quote:
Originally Posted by
Eg. Table Country - *Fields Country Code and Country Name - Both
fields are unique and code is the primary key.
>
Quote:
Originally Posted by
I would like to display something like 'Country code already exists'.
>
Quote:
Originally Posted by
Current display will be 'Duplicate entry 'AA' for key 1'
>
Quote:
Originally Posted by
Is it possible to change key 1 with the name of the field generating
the error ?
>
Quote:
Originally Posted by
Thanks
>
No, MySQL won't do that for you. *If you want something like this, you
can either check for duplicates before the insert like Iván suggested,
or parse the error message yourself.
>
Checking for duplicates before doing an INSERT is OK, but ensure you
LOCK TABLE so someone else doesn't get in between your SELECT and your
INSERT (uncommon, but it does happen!).
>
Alternatively, after you get the duplicate key back, do a SELECT for a
match of Country Code OR Country Name and check the row(s) which come
back to see which is a duplicate.
>
Alternatively, keep track of which index refers to which column and test
in your code. *I like this least of all :-)
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>
- Show quoted text -