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 dot x dot peppler at jpmchase dot com
Subject: Re: How to detect state CS_ROW_FAIL when using ct_fetch
Date: Jun 10 2008 5:56AM

Hi Andrew,

Sybase::CTlib does the following when CS_ROW_FAIL is seen:

    switch(retcode) {
      case CS_ROW_FAIL:                          /* not sure how I should 
handle this one! */
                   if(debug_level & TRACE_FETCH)
                       warn("%s->ct_fetch() returned CS_ROW_FAIL", 
neatsvpv(dbp, 0));
                   /* FALL THROUGH */
      case CS_SUCCEED:
                 fetch2sv(info, doAssoc, wantref);
                 if(wantref) {
                     if(doAssoc) {
 XPUSHs(sv_2mortal((SV*)newRV((SV*)info->hv)));
                     } else {
 XPUSHs(sv_2mortal((SV*)newRV((SV*)info->av)));
                     }
                 } else {
                     for(i = 0; i < info->numBoundCols; ++i) {
                                 sv = AvARRAY(info->av)[i];
                                 if(doAssoc) {
                                     SV *namesv = 
newSVpv(info->datafmt[i].name, 0);
                                     if(debug_level & TRACE_FETCH)
                                                 warn("ct_fetch() pushes 
%s on the stack (doAssoc == TRUE)",
                                                      neatsvpv(namesv, 
0));
                                     XPUSHs(sv_2mortal(namesv));
                                 }
                                 if(debug_level & TRACE_FETCH)
                                     warn("ct_fetch pushes %s on the 
stack",
                                                  neatsvpv(sv, 0));
                                 XPUSHs(sv_mortalcopy(sv));
                     }
                 }
 
                 break;

So this means that CS_ROW_FAIL is really handled like a CS_SUCCEED - 
typically CS_ROW_FAIL will be returned if data is truncated (bind of 
result set item %d was truncated).

You could run your query with Sybase::CTlib::debug(0xffffffff) to get 
trace output and see what is returned. 

Feel free to get back to me (or the list) for further explanations, or if 
you think the behavior is wrong :-)

Michael





andrew.x.dear@jpmchase.com 
Sent by: owner-sybperl-l@peppler.org
09.06.2008 18:35

To
sybperl-l@peppler.org
cc

Subject
How to detect state CS_ROW_FAIL when using ct_fetch







Hello. I'm using the fairly standard code structure to process results 
with Sybase::CTlib. eg something like this: 

   while($dbh->ct_results($restype) == CS_SUCCEED) {
       if($restype == CS_CMD_FAIL) {
           warn "Command failed!";
           next;
       }
       next unless $dbh->ct_fetchable($restype);
       while(@data = $dbh->ct_fetch) {
           print "@data\n";
       }
   } 

After successfully processing some initial rows from the result set, it is 
possible for errors to be received on a row within the result set, the 
result set would then carry on with useful rows of data. Within open 
client, ct_fetch returns a CS_RETCODE (of CS_ROW_FAIL) which would 
indicate what has happened. However within Sybase::CTlib, ct_fetch returns 
the empty array for a failed row exactly as it returns the empty array 
when there are no more results within this result set. 

Do you know how I can detect the difference between CS_ROW_FAIL and the 
end of the result set? 


Thanks for any help,
Andrew


This communication is for informational purposes only. It is not intended 
as an offer or solicitation for the purchase or sale of any financial 
instrument or as an official confirmation of any transaction. All market 
prices, data and other information are not warranted as to completeness or 
accuracy and are subject to change without notice. Any comments or 
statements made herein do not necessarily reflect those of JPMorgan Chase 
& Co., its subsidiaries and affiliates. This transmission may contain 
information that is privileged, confidential, legally privileged, and/or 
exempt from disclosure under applicable law. If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, 
distribution, or use of the information contained herein (including any 
reliance thereon) is STRICTLY PROHIBITED. Although this transmission and 
any attachments are believed to be free of any virus or other defect that 
might affect any computer system into which it is received and opened, it 
is the responsibility of the recipient to ensure that it is virus free and 
no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries 
and affiliates, as applicable, for any loss or damage arising in any way 
from its use. If you received this transmission in error, please 
immediately contact the sender and destroy the material in its entirety, 
whether in electronic or hard copy format. Thank you. Please refer to 
http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK 
legal entities. 

-----------------------------------------
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.