From: | Mathieu <viel(at)benchmark(dot)fr> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | select row value from column's oid |
Date: | 2008-09-24 09:00:46 |
Message-ID: | 0a17a615-34a4-4d21-933b-944b6446d403@c58g2000hsc.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi guys.
I'd like to make a sql request able to get both row value and column
name of a table for a specific id.
Since I need the column name in my process, i first got interested in
a way to get this info from pg tables with this request :
SELECT
a.attname as "column_name"
FROM
pg_catalog.pg_attribute a
WHERE
a.attnum > 0
AND NOT a.attisdropped
AND a.attrelid = (
SELECT c.oid
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'my_table_name_here'
AND pg_catalog.pg_table_is_visible(c.oid)
)
This is working fine but i would like this same request to select both
my "column_name" AND my "row_value"; so i thought : "let's add a JOIN
statement and select my row value depending on my specific id and my
column name or OID or whatever i can find in my pg_attribute
table" ... but i can't find a way to do it!
Any idea? :)
From | Date | Subject | |
---|---|---|---|
Next Message | Howard Cole | 2008-09-24 11:59:06 | pg_dump of non nublic schema causes problems on restore. |
Previous Message | Richard Huxton | 2008-09-24 08:19:13 | Re: Slony vs Longiste |