$sth->execute;
if ($sth->errstr) {
die "Failed to execute ($stmt) - ", $sth->errstr(), "\n";
}
####
use strict;
use DBI;
use DBD::DB2;
my $db2_user = 'USER';
my $db2_pass = 'PASSWORD';
my $dbh = DBI->connect('dbi:DB2:DB2', $db2_user, $db2_pass, {AutoCommit => 0, RaiseError => 0, PrintError => 1}) or die "Cant connect to DB - $DBI::errstr\n";
my $stmt = "select ID from RULE where key = 123";
my $sth = $dbh->prepare($stmt) or die "Cant prepare ($stmt) - $DBI::errstr\n";
$sth->execute or die "Cant execute ($stmt) - $DBI::errstr\n";
if ($sth->errstr) {
die "Failed to execute ($stmt) - ", $sth->errstr(), "\n";
}
print "the execute should have failed before here\n";
my $col1;
$sth->bind_col(1,\$col1);
while ($sth->fetch) { print "id is: $col1\n"; }
print "should not get here\n";
$sth->finish() or die "Cant close sth - $DBI::errstr\n";
$dbh->disconnect() or die "Cant disconnect from DB - $DBI::errstr\n";
####
C:\PerlScripts>test.pl
the execute should have failed before here
DBD::DB2::st fetch failed: [IBM][CLI Driver][DB2] SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: "00C90081", type of resource
: "00000200", and resource name: "SHTDB038.SHTT09Z1". SQLSTATE=57011
should not get here
C:\PerlScripts>