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: Accessing data from a query
Date: Aug 31 1999 8:50PM

Fred Cathey writes:
 > I do a ct_sql query that gets one value.  I have to do a foreach loop to
 > assign it to a variable.  I've tried several different variations on how
 > it was done under DBlib but can't get it to work with CTlib.  How can I
 > assign the single value returned from a database query to a variable
 > without the foreach loop using CTlib?

If your query returns a single row, with a single column (for example: 
"select getdate()") then you can do:

my $data = $dbh->ct_sql($sql);
my $value = $data->[0]->[0];   # first row, first column

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com