Re: Accessing DBCC from DBI

2002-07-03 Thread David L. Good

On Wed, Jul 03, 2002 at 09:43:53AM -0700, Michael Peppler <[EMAIL PROTECTED]> wrote:
> On Wed, 2002-07-03 at 09:28, Accardo, Glen wrote:
> > 
> >  I just tried to prepare/execute/fetch results for the following
> >  a dbcc call in MS SQL Server.  I get an error stating that
> >  there is no select statement running--which is true.
> > 
> >  Is there a mechanism for getting the results of DBCC calls through
> >  DBI?  The do method doesn't seem to return anything more than 
> >  pass/fail, and what I need is all of the output from the 
> >  DBCC calls.
> 
> DBCC output is sent as "error" messages. DBD::Sybase handles this by
> letting you define an ad-hoc error handler. Maybe DBD::ODBC has the same
> sort of functionality.

Nope, DBD::ODBC doesn't have that functionality.  I submitted a patch a
couple of years ago to address the issue, but it kinda got lost in the
shuffle and I moved on to other projects without following up on it.  I
hope to re-integrate the patch into the latest DBD::ODBC soon, but I'm
still trying to get access to an appropriate Windows box...



-- 
David Good[EMAIL PROTECTED]

 This space intentionally left blank.



Re: Accessing DBCC from DBI

2002-07-03 Thread Michael Peppler

On Wed, 2002-07-03 at 09:28, Accardo, Glen wrote:
> 
>  I just tried to prepare/execute/fetch results for the following
>  a dbcc call in MS SQL Server.  I get an error stating that
>  there is no select statement running--which is true.
> 
>  Is there a mechanism for getting the results of DBCC calls through
>  DBI?  The do method doesn't seem to return anything more than 
>  pass/fail, and what I need is all of the output from the 
>  DBCC calls.

DBCC output is sent as "error" messages. DBD::Sybase handles this by
letting you define an ad-hoc error handler. Maybe DBD::ODBC has the same
sort of functionality.

Michael
-- 
Michael Peppler / [EMAIL PROTECTED] / http://www.mbay.net/~mpeppler
[EMAIL PROTECTED] / ZetaTools, Inc / http://www.zetatools.com
ZetaTools: Call perl functions as Sybase stored procedures!



signature.asc
Description: This is a digitally signed message part


Accessing DBCC from DBI

2002-07-03 Thread Accardo, Glen


 I just tried to prepare/execute/fetch results for the following
 a dbcc call in MS SQL Server.  I get an error stating that
 there is no select statement running--which is true.

 Is there a mechanism for getting the results of DBCC calls through
 DBI?  The do method doesn't seem to return anything more than 
 pass/fail, and what I need is all of the output from the 
 DBCC calls.

 Any help is appreciated, and happy 4th!
 glen accardo
 BMC Software, Inc.


-

use strict;
use DBI;

my ($instance, $user, $password, $db) = 
   ('gaccardo', 'sa', 'xxx', 'master');

my $dbh = DBI->connect("dbi:ODBC:DRIVER={SQL Server};".
"SERVER=$instance;".
"DATABASE=$db", {RaiseError => 0, PrintError => 0})
or die "\n\nCannot connect.\n\n$DBI::errstr\n";

DBI->trace(9, 'C:\temp\dbi_trace.txt');

my $sth = $dbh->prepare("DBCC CHECKALLOC");
$sth->execute();

do {
my @query_results;
while (@query_results = $sth->fetchrow_array) {
print join (', ', @query_results) . "\n"
}

} while ( $sth->{odbc_more_results} );

-
DBD::ODBC::st fetchrow_array failed: (DBD: no select statement currently 
executing err=-1) at D:\Qa\mbt\automation\perl\test.pl line 20.