Re: Accessing RECORD variable info - Mailing list pgsql-novice

From Andreas Kretschmer
Subject Re: Accessing RECORD variable info
Date
Msg-id 20070204081534.GA23544@KanotixBox
Whole thread Raw
In response to Accessing RECORD variable info  ("Derrick Betts" <list@blueaxis.com>)
Responses Re: Accessing RECORD variable info  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Derrick Betts <list@blueaxis.com> schrieb:

>
> I have the following in a plpgsql function:
>
> DECLARE
> rec RECORD;
>
> BEGIN
> FOR rec IN EXECUTE 'SELECT * FROM '||table[1]
> LOOP
>   --use the results here
> END LOOP;
>
> How can I determine the actual field name and the field value for the record
> variable (rec) if I were to look in index 1 or 2 or 3 of the variable?

Unfortunately you can't access to row-index, you need the name of the
column. You can do a select on information_schema.columns to retrieve
the column-names:

select column_name from information_schema.columns where table_name = ...




Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."    (unknow)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-novice by date:

Previous
From: "Derrick Betts"
Date:
Subject: Accessing RECORD variable info
Next
From: "Shoaib Mir"
Date:
Subject: Re: connection timeout?