Date: Tue, 10 Apr 2001 15:03:11 -0400
   From: Ranga Nathan <[EMAIL PROTECTED]>

   What would mysql return if:

   1. an INSERT statement is incorrectly coded (expect undef)
   2. correctly coded but due to duplicate row, no insertion possible (expect
   0E0)
   3. successful insert (expect 1)

   I find that in case 2 above, I am getting an undef instead of 0E0. Is this
   the expected behavior?

I get the same (undef,undef,1) that you do (using $dbh->do).

The DBI man page indicates "returns the number of rows affected or undef
on error".  Mysql appears to treat the duplicate primary key case as
an error instead of as a correct statement affecting 0 rows.
(Doing it from within the mysql utility returns "ERROR 1062", which
would confirm that view.)

I take it other databases consider a duplicate primary key to be a
non-error?  I suppose someone could did through the ANSI standard and
see if either view is correct.

--kag

Reply via email to