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: Michael Peppler <mpeppler at peppler dot org>
Subject: RE: return status in last ct_fetch
Date: Feb 11 2004 4:10PM

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?

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

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


> -----Original Message-----
> From: Michael Peppler []
> On Wed, 2004-02-11 at 07:20, Wechsler, Steven wrote:
> > Is there an easy fix for this? The last retrieval from ct_fetch always
> gives
> > me a 0.
> How do you mean that it gives you a 0?
> A normal fetch loop goes like this:
> while(@data = $dbh->ct_fetch) {
>    ...
> }
> This exits when ct_fetch returns either an undef or a zero length array.
> Are you perhaps using "@data" in a scalar context?
> Michael
Michael Peppler                              Data Migrations, Inc.       
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions -