Re: Column existence - how to check?

Поиск
Список
Период
Сортировка
Искать
От
Jeff Boes
Тема
Re: Column existence - how to check?
Дата
Msg-id
9pf6c1$14vi$1@news.tht.net
Список
Дерево обсуждения
Re: Column existence - how to check? "Jeff Boes" <jboes@nexcerpt.com>
In article <20011002.213141.2025187190.16719@localhost.localdomain>, "Mark
Higgins"  wrote:

> I'm writing an app that dynamically creates tables in a postgresql db.
> 
> I'd like to determine if a column has been defined for a known table. Is
> there any way to do this? I've searched around quite a bit and haven't
> found anything.

Well, if your app is written in Perl, and you are using DBD::Pg, then you
can do something like this:

my $sth = $dbh->prepare('select * from mytable');
$sth->execute or die $dbh->errstr;
my @cols = @{ $sth->{NAME_lc} };
if (grep($_ eq 'col_i_want', @cols)) { ... }

-- 
Jeff Boes                                             vox 616.226.9550
Database Engineer                                     fax 616.349.9076
Nexcerpt, Inc.                                      jboes@nexcerpt.com
В списке pgsql-general по дате отправления
От: Neal Lindsay
Дата:
От: Mark Gordon
Дата:
Сообщение: Scalability of postgresql.
FAQ