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: Can't get rid of "pending results"
Date: Nov 3 1997 3:06PM

Jonathan Ham wrote:
> 
> > DB-Library error:
> >         Attempt to initiate a new SQL Server operation with results pending.
> 
> > $dbHandle->dbcmdn($select4);
> > $dbHandle->dbsqlexec;
> > $dbHandle->dbresults;
> > while (@data = $dbHandle->dbnextrow) { print "."; };
> > $dbHandle->dbcmdn($select5);
> > $dbHandle->dbsqlexec;
> > $dbHandle->dbresults;
> > while (@data = $dbHandle->dbnextrow) { };
> 
> Maybe...
> 
> $dbHandle->dbcmdn($select4);
> $dbHandle->dbsqlexec;
> $dbHandle->dbresults;
> while (@data = $dbHandle->dbnextrow) { print "."; };
> $newHandle = Sybase::DBlib->dbopen();   ## Perhaps by opening a new
> $newHandle->dbcmdn($select5);           ## connection, you won't
> $newHandle->dbsqlexec;                  ## be caught waiting for
> $newHandle->dbresults;                  ## the first one to process.
> while (@data = $newHandle->dbnextrow) { };
> 
> I don't know if this solves it -- just a guess.

That would work - but would be seriously sub-optimal.

The correct solution is to always call dbresults in a loop, like this

while(($ret = $dbHandle->dbresults) != NO_MORE_RESULTS) {
   next if $ret == FAIL;   # can't get any data if we had a failure
   while (@data = $dbHandle->dbnextrow) { print "."; };
}

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler