|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: thanks on (RE:any way to get the # of columns returned)
Date: Nov 4 1997 5:47PM
Raja Sambamurty wrote:
>
> Mike,
>
> thanks for the answer and my oversight with the null returns from sql.
>
> I want to ask you an additional question on $db->sql ($sqlcmd).
>
> Is there any way to get the column headings after executing this command
> ? I know $db->dbcolname($colid) works with the dbcmd, dbsqlexec combo;
> is there a trick to get this to work with $db->sql ? (i tried without
> much luck). And I find $db->sql to be very convenient for outputs that
> aren't very large. thanks again.
Use this:
$ref = $db->sql($sqlcmd, undex, TRUE);
foreach $row (@$ref) {
# $row is now a ref to a hash, where the key is the
# column name, and the value the column value for that
# row:
if($row->{empno} == 1234) {
do something for employee # 1234
}
}
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@datamig.com -||- http://www.mbay.net/~mpeppler
|