Thanks for the ideas on alternate ways to get the column
width info. It seems most of the portable methods of
getting column width info don't work with DBD::Pg or
return non-useful values like "-1" for varchars. After
trying a few things, I ended up using an SQL query of the
system catalogs. It's not portable but worked fine for what
I needed. Here's some example code showing how I'm doing it:
my $sth = $dbh->prepare("
SELECT a.attname, format_type(a.atttypid, a.atttypmod)
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'my_table'
AND a.attnum > 0
AND a.attrelid = c.oid
AND a.atttypid = t.oid
ORDER BY attnum
");
$sth->execute();
while(my ($name,$typesize) = $sth->fetchrow_array) {
print "$name $typesize\n";
}
The output looks like this:
userid integer
username character varying(32)
address character varying(64)
city character varying(32)
state character(2)
zip character(10)
startup date
startval numeric(2,0)
....
-Steve
_____________________________________________________________________
R. Steven Rainwater * http://www.ncc.com/humans/srainwater/index.html
"As you struggle to save humanity be sure to avoid electrodes in
your path" -- Robotron 2084