From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | perl: $sth->{TYPE} ...? |
Date: | 2001-09-04 21:48:19 |
Message-ID: | 20010904164819.A8460@serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
in looking for a way to abstract the generation of formatting
methods based on field type (dates=center & formatted; numerics
right-flush; text left-flush, etc) for web pages i've run into a
gap i don't know how to close:
using perl (5.005_03) and DBI (1.13, which refers to
DBD/Pg.pm 0.95), how do i connect $sth->{TYPE} to
$dbh->type_info_all()?
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect('dbi:Pg:dbname=myDB');
my $ATT = $dbh->type_info_all();
my %ref = reverse %{shift(@$ATT)};
my %typ = map {$ATT->[$_]->[1] => $_} (0 .. $#$ATT); # NOT!
#my %typ = map { ...what?... } @$ATT;
my $sth = $dbh->prepare('select * from myTable');
$sth->execute();
my @typ = @{$sth->{TYPE}};
my @nam = @{$sth->{NAME}};
foreach my $f ( 0..$#nam ) {
my $n = shift @nam;
my $t = shift @typ;
print "$n (type #$t) is a ", $ATT->[ $typ->{$t} ]->[0], "\n";
}
$dbh->disconnect();
__END__
i looked through the postgresql.org faq and non-faq areas and
didn't find what i'm looking for...
i'm using the paranoid-haven debian potato, based on older
gadgets, and would like to stay that way (y'all can have the fun
of bleeding on the edge if you want). what's the incantation for
getting postgresql type info from the fields a table (or view)?
--
Hey, let's change the whole justice system. Everybody gets to
kill one person -- if you do two, you go to jail. That should
cut down on the abrasive personalities, don't you think?
will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
From | Date | Subject | |
---|---|---|---|
Next Message | Norbert Zoltan Toth | 2001-09-04 22:20:32 | Re: Index usage question |
Previous Message | Alex Knight | 2001-09-04 21:45:21 | Re: PL/java? |