| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | "Oberpriller, Wade D(dot)" <oberpwd(at)nsc-msg01(dot)network(dot)com> |
| Cc: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Dynamically discovering field names in PLPGSQL queries |
| Date: | 2001-08-21 12:22:53 |
| Message-ID: | 20010821072253.B4270@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Mon, Aug 20, 2001 at 04:44:13PM -0500,
"Oberpriller, Wade D." <oberpwd(at)nsc-msg01(dot)network(dot)com> wrote:
> Is there a way to discover the names of the fields in a record from a SELECT
> statement in PLPGSQL?
>
> For example:
>
> SELECT INTO REC * FROM mytable;
>
> Is there a mechanism to determine what the "*" expanded to? or does a
> programmer always have to know the layout of the table apriori?
I think the following will work:
select attname from pg_attribute, pg_class where attrelid = relfilenode and
attnum > 0 and relname = 'mytable' order by attnum;
I tried this on one of my tables and it looked OK.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | newsreader | 2001-08-21 12:50:19 | Re: Re: is this possible? it should be! |
| Previous Message | Jim Buttafuoco | 2001-08-21 11:53:13 | Re: clustering and/or failover? |