in reply to Re: DBI continuing execution after a warning/informational message
in thread DBI continuing execution after a warning/informational message

thanks for the reply. Yes, i do use DBD::ODBC Your example shows using odbc_more_results while retrieving data.. (fetch)
my code sniffet is here.
$sql = qq{ RESTORE DATABASE ${dbname} FROM disk = '${filename}' ${recovery} , MOVE '$datadev_srcname' TO '$datadev_phyname' , MOVE '$logdev_srcname' TO '$logdev_phyname' ,replace }; } $sth->execute() || die "Restore failed with this error $DBI::errstr nu +m: $DBI:err state: $DBI::state\n" ;
As you can see this is a single command to sql server and i am not sure how do i incorporate your suggestion?
should i change my code to
do{ $sth->execute() || die "Restore failed with this error $DBI::errstr nu +m: $DBI:err state: $DBI::state\n" ; }while ($sth->{odbc_more_results});
I am confused...
thanks

Replies are listed 'Best First'.
Re^3: DBI continuing execution after a warning/informational message
by mje (Curate) on Jan 20, 2010 at 08:58 UTC

    Messages output via print in a procedure are only seen in the DBI error handler so if you want to capture them you need to set that up. There is an example in the 20SqlServer.t test where a procedure is created which prints.

    MS SQL Server, by default does not batch up results and the prints are deemed a result (of a sort). I think you need to call execute then loop whilst odbc_more_results is true.

    $s->execute; while($s->odbc_more_results) { # your error handler will catch prints }
    </code>