Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: John Gilmore-Baldwin <john at dwx dot com>
Subject: Re: sp_spaceused in sybperl
Date: Nov 21 1998 5:03PM

I saved this message in case I ever needed to use this procedure.  Well, I
decided I needed it, but now I fall into an infinite loop.

Here's the loop that won't quit:

$sqlstatement = "sp_spaceused $loresdata{tablename}";
$result = $HiresDBHandle->dbsqlexec;
while ($HiresDBHandle->dbresults != NO_MORE_RESULTS)
	while (@data = $HiresDBHandle->dbnextrow)
		print "@data\n";
	#print "la-de-dah\n";

If I leave in the print statement, the loop is processing.

So, what am i missing?


>Kimber Robbins writes:
> > I am writing a sybperl script to run sp_spaceused and print the output
> > to a file. I am using Sybase::DBlib. I keep getting the following error:
> >
> > DB-Library error:
> >         Attempt to initiate a new SQL Server operation with results
> > pending.
> >
> > Does anyone know why this is happening? Also dbsucceed fails.
>The stored proc returns multiple result sets.
>Call it with $dbh->sql(), or make sure that you execute dbresults() in
>a loop until it returns NO_MORE_RESULTS, like this:
>$dbh->dbcmd("sp_spaceused the_table");
>while($dbh->dbresults != NO_MORE_RESULTS) {
>	while(@dat = $dbh->dbnextrow) {
>		print "@dat\n";    # or whatever you want to do...
>	}
>Michael Peppler         -||-  Data Migrations Inc.
>       -||-
>Int. Sybase User Group  -||-