|
|
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}";
$HiresDBHandle->dbcmd($sqlstatement);
$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?
John
>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");
>$dbh->dbsqlexec;
>while($dbh->dbresults != NO_MORE_RESULTS) {
> while(@dat = $dbh->dbnextrow) {
> print "@dat\n"; # or whatever you want to do...
> }
>}
>
>Michael
>--
>Michael Peppler -||- Data Migrations Inc.
>mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
>Int. Sybase User Group -||- http://www.isug.com
|