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 peppler dot org>
Subject: RE: return status in last ct_fetch
Date: Feb 11 2004 5:50PM

On Wed, 2004-02-11 at 08:19, Wechsler, Steven wrote:
> > From: Michael Peppler [mailto:mpeppler@peppler.org]
> > 
> > On Wed, 2004-02-11 at 08:06, Wechsler, Steven wrote:
> > > Sorry, should have been more specific.
> > > 
> > > I'm using ct_fetch in an array context, exactly as in your 
> > example below.
> > > The last ct_fetch (i.e. before an undef is returned) 
> > returns a 0 in the
> > > first column (probably the only column; haven't checked too 
> > carefully).
> > 
> > Are you fetching the results from a stored procedure?
> 
> Yes.
> 
> > My guess is that you are doing this:
> > 
> > while($dbh->ct_results($restype) == CS_SUCCEED) {
> >    next unless $dbh->ct_fetchable($restype);
> >    while(@data = $dbh->ct_fetch) {
> >       ...
> >    }
> > }
> 
> Actually, I'm not even checking ct_fetchable.

Which means that you're calling ct_fetch() even for $restype values that
have no fetchable results - I guess that's not a problem.

> 
> > A stored proc that includes a SELECT will return at least two result
> > sets, the first one being the SELECT, and the second (last) one is the
> > return status from the proc ($restype == CS_STATUS_RESULT).
> > 
> > Michael
> 
> What's the simplest way to get around retrieving the return status in
> ct_fetch?

(pseudo code...)

while(ct_results($restype) == CS_SUCCEED) {
    while(@data = ct_fetch()) {
       next if $restype == CS_STATUS_RESULT;
       ... process @data here...
    }
}

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
mpeppler@peppler.org                 http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html