$dbh = DBI->connect($dsn, $user, $pass, { RaiseError => 1, AutoCommit => 0 }); #Here we open a locked access to the database my $select_handle; eval{ $dbh->do("BEGIN WORK"); $dbh->do("LOCK TABLE $table"); ###CODE $dbh->do("COMMIT WORK"); };