Forum Moderators: open
Get field names with this command:
describe [tablename];
In your programming, you can use describe to strip off the other table info from describe table (if it's present, depends on your programming) and stuff the field names into an array. A perl example, using the stock DBI module:
@field_list = &table_fields('table_name');
sub table_fields {
my ($sth,$rv,@r,@fields,$table);
$table = shift(@_);
if ($table eq '') { die("No table provided"); }
$sth = $dbh->prepare("describe $table;");
$rv = $sth->execute or &die("Cannot describe table $table");
while ((@r) = $sth->fetchrow_array) { push (@fields, $r[0]); }
$sth->finish;
return @fields;
}