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: "Cross, David" <david dot cross at csfb dot com>
Subject: RE: dereferencing
Date: Sep 11 1998 1:18PM

> ----------
> From: 	pang khong lin[]
> Sent: 	11 September 1998 08:33
> To: 	SybPerl Discussion List
> Subject: 	dereferencing
> $sql = " select something from something";
> $ta_no = $dbh->ct_sql("$sql");
> How do you get the value of $ta_no ? How do you dereference it ? I only 
> have those notes from, anyone has other source of 
> information , examples?
$ta_no will now be a reference to an array. Each element of that array will
be a reference to another array. Each element of these arrays will be a
value returned from the database. To demonstrate:

my ($row, $col);

foreach $row (@$ta_no)
    foreach $col (@$row)
        print "$col\t";
    print "\n";

To directly access the data that's in row $r and column $c use:


Therefore if you know that your statement only returns one row you can
simplify the above to:

my $col;

foreach $col (@{$ta_no->[0]})
    print "$col\t";

And if you know that you your statement only returns one row and one column
you can simplify it even more to:

print "$ta_no->[0][0]\n";

Hope this helps, let me know if you need any more help,