in reply to Re: Reading DB
in thread Reading DB
It shouldn't be necessary to even fetch a single row for this. A WHERE clause that evaluates to false achieves this with minimal impact on the server:
use strict; use DBI; my $dbh = DBI->connect('DBI:database_type:database_name','user','passw +ord') || die DBI->errstr; my $sth = $dbh->prepare("SELECT * FROM table_name WHERE 0=1") || die $ +dbh->errstr; $sth->excecute || die $sth->errstr; my @column_names = @{$sth->{NAME}}; $sth->finish(); # may be unnecessary $dbh->disconnect();
Update Fixed typo in WHERE clause...
Michael
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Reading DB
by Anonymous Monk on Nov 06, 2003 at 23:27 UTC | |
by mpeppler (Vicar) on Nov 07, 2003 at 00:20 UTC |