Hi. I'm new to the mailing list and fairly new to DBI. I looked for an answer from
what I thought was the DBI home
page (http://www.symbolstone.org/technology/perl/DBI/index.html), but I couldn't seem
to access it. My problem is that
I'm inserting data into a table in M$ Access with one $dbh/$sth, then I'm trying to
read it back out for a test using
another $dbh/$sth pair. I don't get the data back that I just inserted, but if I look
at the table directly it's there.
If I run the script again, it works.
I connect to the database with both handles using the form,
my $dbh = DBI->connect( $database, { AutoCommit => 1 } ) or die "Can't connect to
DB $database: $DBI::errstr\n";
Then I execute code to test my data:
$test4->updateChangeRequest( @test_data ); # subroutine with alternate $dbh
to insert the data
my $sth = $dbh->prepare('select AvgTimeOpen, AvgTimeToClose from ChangeTbl C,
DateTbl D
where D.DateID=C.DateID and
D.CollectionDate=#4/14/1994#');
$sth->execute();
my @test_rslt = $sth->fetchrow_array();
$sth->finish();
print "updateChangeRequest(): ", @test_data == @test_rslt ? "PASS" : "FAIL:
@test_data == @test_rslt", "\n";
This test fails in the first run when the data is inserted (which it does insert), but
passes when the data is already
there (the data doesn't get inserted again because of unique key).
I've tried to use the $dbh->commit() in the updateChangeRequest() subroutine, but it
just gives me the expected error of
being ineffective. Is there a problem with using multiple $dbh's?
Jeff