From: | Johan Nel <johan555(dot)nel555(at)xsinet555(dot)co(dot)za> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Determining the names of columns in a dynamic query |
Date: | 2009-04-24 18:27:33 |
Message-ID: | gst0bj$m50$1@news.motzarella.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
Sorry for cross posting, but seems nobody read the pgsql.sql NG. Have
not received any response there so lets see if this create some reaction.
Is it possible in pgsql to have something to manipulate columns where
the column names will only be resolved during execution of the select
statement:
FOR rec IN (SELECT * FROM table)
LOOP
-- This is what I would like to do
FOR col IN (rec.column_names)
LOOP
IF col = 'blahblah' THEN
-- Do something
ELSEIF col = 'nextcol'
--
ELSE
-- Other column
END IF;
END LOOP;
END LOOP;
For the above, it does not need to be exactly the same, but are there a
group of functions available to at least return in a dynamic query the
number of columns, name of a column given the ordinal number of the
column, etc?
TIA,
Johan Nel
Pretoria, South Africa.
From | Date | Subject | |
---|---|---|---|
Next Message | Conrad Lender | 2009-04-24 18:30:45 | Re: standard_conforming_strings and pg_escape_string() |
Previous Message | Brad Nicholson | 2009-04-24 17:40:29 | Re: Selling an 8.1 to 8.3 upgrade |