MySQL Forums
Forum List  »  Perl

Duplicate entry in auto-increment field
Posted by: Mário Antunes
Date: February 08, 2007 06:57AM

Dear all,

I'm having a stange problem:

I'm inserting several entries in tables which has in primary key an auto-increment field.

For example:
create table Ethernet ( \
packet DOUBLE auto_increment,\
time DATETIME,\
src_mac VARCHAR(12),\
dest_mac VARCHAR(12),\
type VARCHAR(5),\
primary key (packet)\
);

When I'm inserting the entries (using Perl DBI) I got, here and there, a "Duplicate entry 'xxxxx' for key 1". It is strange, since the key 1 is an auto-increment field. I assume mysql deals with this issue.

The code I'm using is:

my $sth = $dbh->prepare('INSERT INTO Ethernet VALUES (?,?,?,?,?)');
die "Error preparing INSERT statement; aborting" unless defined $sth;
$sth->execute($packet,$time,$src_mac,$dest_mac,$type_proto) or print "ERR:xxx";

Any help is welcome.

Regards,

Mário

Options: ReplyQuote


Subject
Written By
Posted
Duplicate entry in auto-increment field
February 08, 2007 06:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.