hi foo
tried it - no output whatsoever....
ideas?
<quote who="Foo Ji-Haw">
>> hello colleagues
>>
>> i have this snippet of code that works well:
>> =================
>> $query = qq(SELECT * FROM smalllabor;);
>> $sth = $dbh->prepare($query);
>> $sth->execute() or webdb4::dberr_trap("Unable to get table info");
>> while(my $row_href = $sth->fetchrow_hashref)
>> {
>> print "$row_href->{'area'}\n"; ##prints column 'area' for all
>> rows
>> }
>> ==================
>> but now assume for a moment that i dont know the columns in the table so
>> i
>> cant use [print "$row_href->{'area'}\n";] anymore (i would not know
>> that
>> there is a column 'area').
>>
>> how can i get the column names - what i presume to be the keys to the
>> hashref? assume that i just want to list the column names.
>>
> Try this:
> foreach my $key (keys %$row_href)
> {
> print "$key = ".$row_href->{$key}."\n";
> }
>
> Suggest that you don't use qq in your first line:
> my $query = 'SELECT * FROM smalllabor';
>
> Is much easier to read. :)
>
>
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs