Subject: | Placeholders not working for UPDATE statements |
Hi,
The following demonstrates a bug in SQLite or DBD::SQLite 0.29:
-------------------------
[sol2:~/bin/test] % perl -nle 'print "$.\t$_"' sqlite-test.pl
1 use strict;
2 use DBI;
3
4 my $dbh = DBI->connect('dbi:SQLite:dbname=test', undef, undef,
5 {RaiseError => 1});
6
7 $dbh->do("CREATE TABLE foo (a, b)");
8 $dbh->do("INSERT INTO foo VALUES (1, 2)");
9 $dbh->do("INSERT INTO foo VALUES (2, 4)");
10
11 my $sth = $dbh->prepare("SELECT oid FROM foo");
12 $sth->execute;
13 while (my ($oid) = $sth->fetchrow_array) {
14 $dbh->do("UPDATE foo SET a=7 WHERE oid = ?", undef, $oid);
15 }
[sol2:~/bin/test] % rm -f test ; perl sqlite-test.pl
DBD::SQLite::db do failed: at sqlite-test.pl line 14.
DBD::SQLite::db do failed: at sqlite-test.pl line 14.
-------------------------
If I do the UPDATE query without being nested inside the SELECT query,
it seems to work fine. So maybe some routine isn't re-entrant or
things are otherwise stomping on each other.
-Ken