Subject: | Cannot execute prepared statement twice |
my $sth= $dbh->prepare ("select * from foo where id = ?");
should be excutable multiple times. Currently it is not
The below patch adds the test case
The error is as follows:
prove -wvb t/43-cursor.t
t/43-cursor.t ..
1..27
ok 1 - Connected to the database
ok 2 - TABLE is 'TESTAE'
ok 3 - CREATE TABLE 'TESTAE'
ok 4 - PREPARE INSERT
ok 5 - INSERT id 6
ok 6 - INSERT id 1
ok 7 - INSERT id 2
ok 8 - STH
ok 9 - Excute for 1
ok 10 - Fetch for 1
ok 11 - Comment for 1
ok 12 - Excute for 2
DBD::Firebird::st fetchrow_array failed: The cursor identified in an OPEN statement is already open.
-Dynamic SQL Error
-SQL error code = -502
-Attempt to reopen an open cursor at t/43-cursor.t line 65.
Use of uninitialized value in null operation at t/43-cursor.t line 65.
--8<---
diff --git a/t/43-cursor.t b/t/43-cursor.t
index 3edb64f..af30fb7 100644
--- a/t/43-cursor.t
+++ b/t/43-cursor.t
@@ -28,7 +28,7 @@ unless ( $dbh->isa('DBI::db') ) {
plan skip_all => 'Connection to database failed, cannot continue testing';
}
else {
- plan tests => 17;
+ plan tests => 27;
}
ok($dbh, 'Connected to the database');
@@ -59,6 +59,13 @@ ok($cursor->execute($_, $values{$_}), "INSERT id $_") for (keys %values);
$dbh->{AutoCommit} = 0;
+ok (my $sth = $dbh->prepare("select comment from $table where user_id = ?"),"STH");
+foreach my $id (sort keys %values) {
+ ok($sth->execute($id),"Excute for $id");
+ ok(my($c)=$sth->fetchrow_array(),"Fetch for $id");
+ is($c,$values{$id},"Comment for $id");
+}
+
my $sql_sele = qq{SELECT * FROM $table WHERE user_id < 5 FOR UPDATE OF comment};
ok(my $cursor2 = $dbh->prepare($sql_sele), 'PREPARE SELECT');
-->8---