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:
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?
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:
for example: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;
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: SELECT LAST_INSERT_ID does not work
by Corion (Patriarch) on Jun 28, 2017 at 06:05 UTC | |
Re: SELECT LAST_INSERT_ID does not work
by poj (Abbot) on Jun 28, 2017 at 06:33 UTC | |
Re: SELECT LAST_INSERT_ID does not work
by Marshall (Canon) on Jun 28, 2017 at 06:06 UTC | |
Re: SELECT LAST_INSERT_ID does not work
by afoken (Chancellor) on Jun 28, 2017 at 18:01 UTC | |
Re: SELECT LAST_INSERT_ID does not work
by chacham (Prior) on Jun 28, 2017 at 20:37 UTC | |
by afoken (Chancellor) on Jun 29, 2017 at 04:17 UTC | |
by chacham (Prior) on Jun 29, 2017 at 20:15 UTC | |
by afoken (Chancellor) on Jun 30, 2017 at 20:55 UTC | |
by chacham (Prior) on Jul 01, 2017 at 19:03 UTC | |
| |
Re: SELECT LAST_INSERT_ID does not work
by Anonymous Monk on Jun 28, 2017 at 05:20 UTC |
Back to
Seekers of Perl Wisdom