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: Curt Tilmes <curt at ltpmail dot gsfc dot nasa dot gov>
Subject: ct_sql() on CS_CMD_FAIL
Date: Sep 25 1997 5:22PM

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->{'ROW_COUNT'} = $db->ct_res_info(&CS_ROW_COUNT)
            if $res_type == &CS_CMD_DONE;
        next unless $fetchable{$res_type};

        while (@data = $db->ct_fetch($flag)) {
            last if($max && ++$count > $max);
            if (defined $sub) {
                &$sub(@data);
            } else {
                if($flag) {
                    push(@res, {@data});
                } else {
                    push(@res, [@data]);
                }
            }
        }
        $db->ct_cancel(&CS_CANCEL_CURRENT) if($max && $count > $max);
    }
    $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?

Curt