Vagabundo has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have two scripts using the same mysql-database with DBI and the same table. One of this scripts add sometimes a lot of inserts.
The other script than has a problem to get the correct LAST_INSERT_ID.
It looks like the busy script makes entries at the same time between my Insert and my SELECT LAST_INSERT_ID.
Is that real possible and how can I prevent it.

My Code is:
my $sthopen = $dbh->prepare("INSERT INTO..... $sthopen->execute; &ErrorDBI; my $resid = $dbh->prepare("SELECT LAST_INSERT_ID()"); $resid->execute; &ErrorDBI; my @idrow = $resid->fetchrow_array;
for example:

The auto_increment entry is 2201 and the last_insert is 2203
or 2504 and 2505
and so on.....
Has anybody an idea for an solution?