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?
 
[EMAIL PROTECTED]
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl

Reply via email to