----- Original Message -----
From: "Scott Haneda"
> on 5/4/05 7:22 PM, Paul DuBois at paul@stripped wrote:
> > Error strings do change format sometimes.
> > And they won't necessarily be in English. :-)
> I had a feeling, what is the general method most use to deal with the
> scenario? I really don't want to test error strings every time I update
> mysql, I suppose the safe road is to hand select ahead of time?
INSERT new record with username
retrieve record id (if it is an autoincrement field)
UPDATE record with email
You can now handle the 1062 errors of the insert and update seperately.
The scenario with select, insert requires transactions (other processes
could insert a matching record between your select and insert), which are
currently only supported by InnoDB (and BDB) tables.
Another approach would be to do an insert with username and email and in
case of an error do one or two selects to check which field caused the
duplicate error (most of the time there won't be an error, so it would save
you some queries).