http://qs321.pair.com?node_id=504006


in reply to Re^2: Getting MSSQL message return on DBI
in thread Getting MSSQL message return on DBI

I am not sure I understand your question. But if you are wondering how to get the results of a statement handle with multiple result sets you should have code like:
my @rs; #result set do { while( my $hr = $sth->fetchrow_hashref ){ push @rs, $hr; } #process @rs (array of hashrefs in order the server returned them ) } while ( $sth->{odbc_more_results} );
If your question is about the error still, then you need to read perldoc DBI and DBD::ODBC for more specifics on how errors are handled an some suggestions on methods to do that. There are some additional flags you can set in both the db handle such as { RaiseError=> 1 } and in the statement handle. In general a common error handle method is to wrap your calls in eval {}; and check $@.

Replies are listed 'Best First'.
Re^4: Getting MSSQL message return on DBI
by shonorio (Hermit) on Oct 30, 2005 at 18:49 UTC
    This query do not return a 'selected table result' like, they output DBCC print message like bellow, and because this I cant not get values by fetch* DBI method.
    DBCC SHOWCONTIG scanning 'Orders' table... Table: 'Orders' (21575115); index ID: 1, database ID: 6 TABLE level scan performed. - Pages Scanned................................: 20 - Extents Scanned..............................: 5 - Extent Switches..............................: 4 - Avg. Pages per Extent........................: 4.0 - Scan Density [Best Count:Actual Count].......: 60.00% [3:5] - Logical Scan Fragmentation ..................: 0.00% - Extent Scan Fragmentation ...................: 40.00% - Avg. Bytes Free per Page.....................: 146.5 - Avg. Page Density (full).....................: 98.19% DBCC execution completed. If DBCC printed error messages, contact your + system administrator.
    Talking about Win32::OLE, I can do this with a code like bellow. I need to translate the Win32::OLE code to DBI, but I can't see a way to get theses messages.
    Solli Moreira Honorio
    Sao Paulo - Brazil