List:General Discussion« Previous MessageNext Message »
From:Scot Campbell Date:September 18 2003 3:20pm
Subject:Re: Unique Key Violation - How to determine which key
View as plain text  
O.K., I understand.  And I have always coded in this manner.

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 <Jeremy@stripped>
>Reply-To: mysql@stripped
>To: Scot Campbell <scotcampbell@stripped>
>CC: mysql@stripped
>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!
><Jeremy@stripped>  |  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/mysql?unsub=1
>

_________________________________________________________________
Get 10MB of e-mail storage! Sign up for Hotmail Extra Storage.  
http://join.msn.com/?PAGE=features/es

Thread
Unique Key Violation - How to determine which keyScot Campbell17 Sep
  • Re: Unique Key Violation - How to determine which keyJeremy Zawodny17 Sep
  • Permission Problem in OS XDietrich Speer23 Jan
    • Re: Permission Problem in OS XBrent Baisley23 Jan
Re: Unique Key Violation - How to determine which keyScot Campbell17 Sep
  • Re: Unique Key Violation - How to determine which keyJeremy Zawodny17 Sep
Re: Unique Key Violation - How to determine which keyScot Campbell18 Sep
  • Re: Unique Key Violation - How to determine which keyJeremy Zawodny18 Sep
  • Re: Unique Key Violation - How to determine which keyHarald Fuchs18 Sep
Re: Unique Key Violation - How to determine which keyScot Campbell18 Sep
  • Re: Unique Key Violation - How to determine which keyJeremy Zawodny18 Sep