I'm trying to store the runtime mssql error in variable and continue with all other data.
my $sth = $dbh->prepare("exec TEST_ABC_DB.dbo.testprocedure");
$sth->execute() ;
my $db_error =$DBI::errstr; #It didn't work also I tried err and state
print "\nDB error $db_error\n";
while (@row = $sth->fetchrow_array( ) )
{
print "Row: @row\n";
}
I used the eval block but it is also not working.
My procedure as follows,(sample)
CREATE procedure testprocedure as
select 'one'
select 'three'
select 10/0
select 'five'
When I run the script it shows
The output is
Row: one
DBD::ODBC::st finish failed: [unixODBC][FreeTDS][SQL Server]Divide by zero error encountered. (SQL-22012) at testing.pl line 24.
DBI::db=HASH(0xbe79a0)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at testing.pl line 28.
Not displaying output even three
. Displays the only one.
https://msdn.microsoft.com/en-us/library/ms175976.aspx
– Incurrent