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: $dbh->ct_res_info(CS_ROW_COUNT) problems
Date: Jan 4 2002 5:35PM

Ioffe, Dimitry writes:
 > Hello all,
 > Can someone pls. point me as to what am I missing.  I'm running following
 > code:
 > ....
 > 
 >                 $status=$dbh1->ct_execute("
 >                         select '\"'+
 > name+'\",\"'+type+'\",\"'+convert(varchar,crdate)+'\"' from
 > $dbName1..sysobjects
 >                         where type not in ('S', 'D') 
 > 		 ");
 > 
 >                 while ($dbh1->ct_results($restype) == CS_SUCCEED) {
 >                 next if ($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL
 > || $restype == CS_CMD_SUCCEED);
 > 	    if ($c = $dbh1->ct_res_info(CS_ROW_COUNT)) {
 >         		print "$c";
 > 	    }
 >                 while (@dat=$dbh1->ct_fetch) {
 > ....
 > 
 > and the err. msg. I'm getting is:
 > 
 > Open Client Message:
 > Message number: LAYER = (1) ORIGIN = (1) SEVERITY = (1) NUMBER = (42)
 > Message String: ct_res_info(ROWCOUNT): user api layer: external error: This
 > routine cannot be called after ct_results() returns a result type of
 > CS_ROW_RESULT.

See the Sybase manual for ct_res_info():

CS_ROW_COUNT: The number of rows affected by the current command.
Can be called only after a ct_results() of type CS_CMD_DONE,
CS_CMD_FAIL or CS_CMD_SUCCEED.

To expand on that - Sybase doesn't know the number of rows that it
will return to you until it has processed all the rows - so calling
ct_res_info(CS_ROW_COUNT) before all the rows have been fetched can't
return any valid information.

Michael
-- 
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
mpeppler@peppler.org - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com