Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: jander at lehman dot com (Jim Anderson)
Subject: Re: de-referencing pointers
Date: Mar 26 1996 2:24PM

> Help!   I'm corn-fused!  I need to execute a SQL statement that returns only a
> single value.  I use $ref=$handle->sql(...) to execute it.  But I can't seem to
> access the returned value in a single statement.  I'm sure my syntax is screwed
> up somewhere, but I can't figure it out.  Here's an example:
> $ref=$dbh->sql("select getdate()");   # this returns a pointer to an array of
> pointers
> $ref2=$$ref[0]; # 		this returns a pointer to the first (and only)
> row                                                          
> $date=$$ref2[0];         # this returns the actual value
> I'm trying to set the $date value without having to set the intermediate $ref2
> value.
> Shouldn't I be able to assign $date directly, e.g. $date=$${$$ref[0]}[0]?
> Tom Wilson

How about something really simple?

	$dbh->sql( "select getdate()", sub {$date = shift} );

Jim Anderson					Phone:  (201)524-4076
Lehman Brothers, Inc.				Fax:	(201)524-5153 
101 Hudson Street, 34th Floor			E-mail:
Jersey City, NJ 07302