I am using this in a program that is accessing a MyISAM table in MySQL. I issue a write lock on several tables in the same schema, but not this table named "vocabulary." Then when I try to do a SELECT on vocabulary I get the error "DBD::mysql::st execute failed: Table 'vocabulary' was not locked with LOCK TABLES" on the $sth->execute line in the above sub. I have tested the SQL statement being executed and it is valid. I have no clue what the problem is, since it is correct that I have not locked that table! Anyone know what's going on?sub getsqlvalue { my @results = (); my ($dbh,$sqlstatement)= @_; my $sth = $dbh->prepare($sqlstatement); my @row; $sth->execute || die "Could not execute MySQL statement: $sqlstate +ment"; while (@row=$sth->fetchrow_array) { push(@results, [ @row ]); } $sth->finish(); return $results[0][0]; }
Many TIA
Steve UPDATE I found the answer in the MySQL docs for lock tables: "When you use LOCK TABLES, you must lock all tables that you are going to use in your queries." So the problem was indeed that I had not locked the table.
In reply to DBD::Mysql Strange Locking error by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |