Throw the data at the system and see if it sticks. In most cases it will.
However, when it does fail, it would be nice to determine the error w/o issuing more calls.
So, the school solution is, "When a unique constraint is violated, issue selects for each of the unique contrained columns to determine which one was violated"?
Thanks
From: Jeremy Zawodny <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: Scot Campbell <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: Unique Key Violation - How to determine which key Date: Wed, 17 Sep 2003 21:48:23 -0700
On Wed, Sep 17, 2003 at 03:07:41PM -0700, Scot Campbell wrote:
> These will be random atomic Inserts originating from a Web page.
>
> I'm not sure I catch your drift. The inserts are not in a batch.
>
> I need to notify the user on the page which field was in error. I'd like to
> refer to the index name in the schema and relate it to the field that
> contains the non-duplicate data (i.e., error message on the email address
> vs. error message on the userid field).
What I'm saying is this.
If you expect most inserts to succeede, then code that way.
Insert a row. If it fails, then go to the effort of finding the offending key.
Otherwise, if you check every key before the insert, you're wasting effort most of the time.
That's all. -- Jeremy D. Zawodny | Perl, Web, MySQL, Linux Magazine, Yahoo! <[EMAIL PROTECTED]> | http://jeremy.zawodny.com/
MySQL 4.0.15-Yahoo-SMP: up 4 days, processed 158,913,444 queries (438/sec. avg)
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
_________________________________________________________________
Get 10MB of e-mail storage! Sign up for Hotmail Extra Storage. http://join.msn.com/?PAGE=features/es
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]