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: Data retrieval
Date: Nov 15 1999 3:28PM

Hrvoje Niksic writes:
 > Based on the code in some examples, people at my company use the
 > following construct to retrieve data from a select:
 > $dbh->ct_execute("select ...");
 > while($dbh->ct_results($restype) == CS_SUCCEED) {
 >   next unless $dbh->ct_fetchable($restype);
 >   while (my %data = $dbh->ct_fetch(1)) {
 >     # ... code here ...
 >   }
 > }
 > Having two while loops for looping through one set of rows seems kind
 > of ugly.  Is it possible to have only one loop?  I guess I could write
 > a function that calls ct_results(), ct_fetchable(), and ct_fetch(),
 > but it might be non-trivial because the function should remember its
 > state information somewhere.
 > I was wondering if there was any existing functionality to do that.

You could check out the module, on my web page.

Other than that - the above loop is what *must* happen, although there 
are of course lot's of ways to code it...

Michael Peppler         -||-  Data Migrations Inc.    -||-
Int. Sybase User Group  -||-
Sybase on Linux mailing list: