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: CT_Execute Question
Date: Apr 22 2002 2:21PM

On Mon, 2002-04-22 at 06:55, Sabherwal, Balvinder (MBS) wrote:
> Is it possible to do something like as below?? I don't get any outputs from
> the code below. Am I doing something wrong??

Yes :-)

ct_col_names() returns the column names for a result set. For it to work
you have to have called ct_results(), and the $restype must be one of
the fetchable result types.

So you need to change your code to something like this:

my $cmde = "select * from sysdatabases";
my ($dr,@data,$ret); 
$dbh->ct_execute($cmde);

while($dbh->ct_results($ret) == CS_SUCCEED) {
    next unless $dbh->ct_fetchable($ret);
    my @cols = $dbh->ct_col_names;
    foreach my $kv (@cols) {
        print "$kv\n";
    }
    while($dr = $dbh->ct_fetch) {
        #   push(@data,$dr) unless($dr eq "0" && $dr == 0);
            print "$dr\n";
    }
}

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