Why not directly use field1 and field2? Perhaps if the SQL sentence with a
'select * from table1', then it might be meaningful to some extend by
dynamically check the column names for something to do?

Bao

Ian Harisay wrote:

> Hi,
> Does anyone know how to generate column headers for output based on the SQL.
> my $sth = $dbh->prepare("SELECT field1, field2 FROM table1");
> $sth->execute;
>
> print $headers ## how would I do this based on the fields returned??
>
> while ( my $rec = $sth->fetchrow_arrayref ){
>   print join(", ", @{ $rec } ), $/;
> }
>
> Thanks,
>
> Ian

--
BAO RuiXian, PROGRAMMER, Technologies Team,  Project Services Group
AtBusiness Communications Corp., Kaapeliaukio 1, FIN-00180 Helsinki
tel. +358-9-2311 6674, mob. +358-50-329 6275,  fax +358-9-2311 6601
http://www.atbusiness.com, email: [EMAIL PROTECTED]


Reply via email to