On Thu, Jan 05, 2006 at 03:17:02PM -0500, Colton A Smith wrote:
> SELECT attname, typname, attnum
> FROM pg_attribute INNER JOIN pg_type
> ON pg_attribute.atttypid = pg_type.typelem
> WHERE pg_attribute.attrelid = $oid (derived above)
> AND NOT attisdropped;
The join condition for pg_type should be against pg_type.oid, not
pg_type.typelem. A simplified version of your two queries is:
SELECT attname, atttypid::regtype, attnum
FROM pg_attribute
WHERE attrelid = 'organic_matter'::regclass AND NOT attisdropped;
--
Michael Fuhr