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

I am using the Perl DBI to manipulate an Access database.
The database can also be altered by forms using the normal Access tools.
Is there a way of:
1. preventing the Perl application from modifying (or even getting access to) the
database when it is open by someone who is changing the database (using the normal
access tools)
2. preventing the database being changed using the Access tools whilst the database is
being used by the Perl application?

Replies are listed 'Best First'.
Re: Locking Access Records and Database
by ikegami (Patriarch) on Apr 08, 2008 at 11:02 UTC

    Locking on the Perl side is done the SQL "LOCK" statement.

    On the Access side, forms have properties that control locking.

      Thank you for your suggestions.

      I have tried to use the SQL LCOK in the following way after I found a reference that said
      LOCK TABLES table_name WRITE will provide a lock but let me write records
      to the table.
      $lock_res = 'unset'; $lock_str = "LOCK TABLES " . $table . " WRITE"; $lock_res = $dbh->do($lock_str); print "[lock_table] locking table <$table> result <$lock_res>\n";
      However, this does not seem to have worked since
      1. $lock_res did not contain anything after the code;
      2. I could use Access normally to alter data in the table.
      What am I doing wrong?

        So what's the error message ($dbh->errstr)?