Aug 24, 2015, 5:15 AM
Post #1 of 2
err, state & errstr captured only on fetarray, not on execute
I am new to the perl world. I am trying to connect to a odbc data source, execute a procedure and fetch the o/p result set.
Now the procedure I am calling, I know, will error out (because of deliberate raiseeror in an attempt to test the error handling). But when I execute the script the error is captured not in $sth->execute(), instead at sth->fetcharray_hashref().
I am doing this with a non-standard ODBC driver (I mean ODBC driver of a non-relational database).
Below is the code snipped I am trying:
my $dbh = DBI->connect('dbi:ODBC:testing', '', '') or die "ERROR: Failed to connect, $DBI::errstr";
my $query = "exec testing.parent";
my $sth = $dbh->prepare($query) or die "ERROR: Failed prepare of stmt to fetch proc parms, $DBI::errstr";
my $temp = $sth->execute();
my $errstr = $sth->errstr();
print "ret $temp\n"; # pirnts -1
print "$errstr\n"; # Says $errstr is uninitialized
my $array = $sth->fetchrow_hashref(); # Throws error
$errstr = $sth->errstr();
print "$errstr\n"; # prints the intended error string
Is this a normal behavior? or is this problem with the non-standard odbc driver vendor provided?
As per my requirements, I have to capture the SQL Error after execute.