PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: sp_spaceused in sybperl
Date: Nov 23 1998 5:44PM

John Gilmore-Baldwin writes:
 > 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?

Don't know.

This script works fine here:

#!/usr/local/bin/perl -w

use strict;
use Sybase::DBlib;

my $dbh = new Sybase::DBlib 'sa';   #### yeah I know I should have a
				    #### password here ;-)

print "$Sybase::DBlib::Version\n";

#$dbh->dbuse('testdb');
$dbh->dbcmd("sp_spaceused sysusers");
$dbh->dbsqlexec;
while($dbh->dbresults != NO_MORE_RESULTS) {
    while(my @data = $dbh->dbnextrow) {
    }
}

__END__

So what could be different between the two?

Michael

 > 
 > 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
 > 
 > 
 > 

-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@mbay.net       -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com