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 MBAY dot NET>
Subject: Re: ct_sql() on CS_CMD_FAIL
Date: Sep 25 1997 6:10PM

Curt Tilmes wrote:
> 
> ct_sql() returns undef only if ct_execute() returns other than
> CS_SUCCEED.
> 
> Even if I have a totally bogus query, it just returns nothing instead
> of undef.
> 
> I think it should check for CS_CMD_FAIL, and return undef in that case.
> 
> To that end, I added these three lines to ct_sql():
> 
> [...]
> >>>>my $fail = 0;
>     while(($rc = $db->ct_results($res_type)) == &CS_SUCCEED) {
> >>>>>>>>$fail = 1 if $res_type == &CS_CMD_FAIL;



>     $db->{RC} = $rc;
> >>>>return undef if $fail;
>     wantarray ? @res : \@res;  # return the result array
> 
> Am I going about this totally wrong?  Will I break anything by adding
> this?

I sent a message to the list about a week ago regarding the same 
problem.

My solution was to set $db->{RC} to CS_FAIL if ct_results receives
a $res_type of CS_CMD_FAIL. The reason for doing this is that your
command might include several result sets. Even if it fails at some
point it makes sense to return the rows that were successfully 
retrieved.

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler