in reply to "DESCRIBE" Command via DBI?
Note, most DBDs only populate NAME after the execute, and you need the finish() if you don't actually fetch rows. DBI also provides the table_info() and column_info() methods. Also, if there are commands like EXPLAIN in your variant of SQL, DBI will happily pass those along to your RDBMS.my $sth = $dbh->prepare("SELECT * FROM $table WHERE 1=0"); $sth->execute; my @fields = @{$sth->{NAME}}; $sth->finish;
updateAlso note that if portablity is a concern, use $sth->{NAME_lc} or $sth->{NAME_uc} instead of $sth->{NAME}. That way you'll get the field names in the same case from all RDBMSs.
|
|---|