Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Getting MSSQL message return on DBI

by JamesNC (Chaplain)
on Oct 30, 2005 at 13:57 UTC ( [id://503996]=note: print w/replies, xml ) Need Help??


in reply to Getting MSSQL message return on DBI

The reason you get this error is because of the statement "use Northwind" the solution:
1) execute that statement in a separate statement handle
-- OR BETTER --
2) use fully qualified statements ( which is the most correct and you should ALWAYS do ;-) Fully qualified means to do something like
select A.[Column Name] from [Database Name].[owner].[Table Name] A
Most applications like SQL Query Analyzer parse the use statement out for you and that is why you might think it is ok to use.
JamesNC

Replies are listed 'Best First'.
Re^2: Getting MSSQL message return on DBI
by shonorio (Hermit) on Oct 30, 2005 at 14:37 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://503996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found