Jeanh
November 9th, 2006, 05:05 PM
Hi,
I have an access database with a single simple table.
Jobid Status
1 busy
2 busy
3 free
4 free
5 free
When a user wants the next job, I SELECT the next lowest free number and UPDATE the status to 'busy'. A job can take a random amount of time to complete before that user requests another job.
Problems happen when multiple users access the database. Everything goes out of sync.
I tried ADO and DBI, both have the same problem. The connections don't seem to update the changes made by the other connections until it's too late. Some jobs get processed multiple times! The connections are always open. If I reconnect each time to get a job the problem goes away because the data is refreshed in each connection.
SELECT:
my $SQL = "SELECT JOBID, FILE FROM MYTABLE WHERE JOBID=(SELECT MIN (JOBID) FROM FILESET WHERE STATUS=?)";
UPDATE:
my $SQL = "UPDATE FILESET SET STATUS=? WHERE JOBID=?";
my $obj = $dbh->prepare($SQL);
$obj->execute($new_status,$record->{JOBID});
$obj->finish;
}
Thanking you in advance. I'm losing hours of sleep!
I have an access database with a single simple table.
Jobid Status
1 busy
2 busy
3 free
4 free
5 free
When a user wants the next job, I SELECT the next lowest free number and UPDATE the status to 'busy'. A job can take a random amount of time to complete before that user requests another job.
Problems happen when multiple users access the database. Everything goes out of sync.
I tried ADO and DBI, both have the same problem. The connections don't seem to update the changes made by the other connections until it's too late. Some jobs get processed multiple times! The connections are always open. If I reconnect each time to get a job the problem goes away because the data is refreshed in each connection.
SELECT:
my $SQL = "SELECT JOBID, FILE FROM MYTABLE WHERE JOBID=(SELECT MIN (JOBID) FROM FILESET WHERE STATUS=?)";
UPDATE:
my $SQL = "UPDATE FILESET SET STATUS=? WHERE JOBID=?";
my $obj = $dbh->prepare($SQL);
$obj->execute($new_status,$record->{JOBID});
$obj->finish;
}
Thanking you in advance. I'm losing hours of sleep!