Manisha,

I think this is in the archives, or it was discussed recently. 

Anyway, here's a snippet that shows how to do it:

for ($i=0;$i<$csr->{NUM_OF_FIELDS};$i++) {
        print "Field $i: $csr->{NAME}->[$i]\n";
}       

if you get your results back in an arrayref:

while ( $arrayRef = $csr->fetchrow_arrayref) {

you can easily match the names to the column data.

Regards,

Tim 

PS this info is also in "Programming the Perl DBI". There are other staement
handle attributes as well: NAME_uc, NAME_lc, TYPE, PRECISION etc..


-----Original Message-----
From: Manisha Gupta [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 18, 2003 5:57 PM
To: [EMAIL PROTECTED]
Subject: retrieving column names from a table using DBI module


Hello
I am working with Perl CGi. There is a query where i have to select all
columns in  a table and display the data on the web page.
the query is something like 
"select * from <tablename>
But the problem is I am not able to get the column names.
I am using the DBI module. Is there a way to get column names?

Thanks

Reply via email to