You might also try (you might have to change the query to actually return a 
row):


my $sth = $dbh->prepare("select * from myTable where 1=2");
$sth->execute;
my $rc = $sth->fetchrow_hashref;
foreach my $key (keys %{$rc}) {
  print $key;
}
$sth->finish;
Sorry for any typos as I'm not using a proper keyboard.

Bart

Begin forwarded message:

From: Michael Dickens <[email protected]>
Date: March 11, 2010 13:43:17 CST
To: "Houston.pm located in Houston, TX." <[email protected]>
Subject: Re: [pm-h] Fields names froma table
Reply-To: "Houston.pm located in Houston, TX." <[email protected]>


Hi Fraser,
have you tried using a query 'DESC my_table' and then fetchrow_array something 
like:

my $sth = $dbh->prepare("DESC my_table");
$sth->execute();
my @fields = $sth->fetchrow_array;
$sth->finish();



Michael

On Thu, Mar 11, 2010 at 11:32 AM, Fraser Baker <[email protected]> wrote:
Hi:
 
OK, I finally have a question.
 
How do I get a list of field names from a mySQL table using DBI? I don't need 
the values.
 
I have put my time in, but can't get it to work.
 
Fraser

_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/



-- 
easy as Perl
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/



      
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/

Reply via email to