Re: Accessing RECORD variable info

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Accessing RECORD variable info
Date: 2007-02-04 08:15:34
Message-ID: 20070204081534.GA23544@KanotixBox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Derrick Betts <list(at)blueaxis(dot)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°

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Shoaib Mir 2007-02-04 08:35:20 Re: connection timeout?
Previous Message Derrick Betts 2007-02-04 07:46:42 Accessing RECORD variable info