Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Getting MSSQL message return on DBI

by shonorio (Hermit)
on Oct 30, 2005 at 14:37 UTC ( #504000=note: print w/replies, xml ) Need Help??


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

You are correct, and I found at DBD::ODBC Tutorial Part 3 - Connecting Perl on UNIX or Linux to Microsoft SQL Server another way, using $dbcon->{odbc_exec_direct} = 1;.

Now, I'm looking for a way to get the result of this code, that return by error message.

Thank you

Solli Moreira Honorio
Sao Paulo - Brazil

Replies are listed 'Best First'.
Re^3: Getting MSSQL message return on DBI
by JamesNC (Chaplain) on Oct 30, 2005 at 15:40 UTC
    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 $@.
      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://504000]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2020-12-01 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (11 votes). Check out past polls.

    Notices?