Possible to access value in RECORD without knowing column name?

From: "Collin Peters" <cadiolis(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Possible to access value in RECORD without knowing column name?
Date: 2007-05-02 19:17:08
Message-ID: df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In plpgsl, if I have a RECORD variable that is populated via some
dynamic SQL, is it possible to access the columns in that RECORD
object without knowing the column names? I.e. Can I grab whatever
value is the 3rd column?

random_colname = 'foobar';
sql = 'SELECT col1, col2, ' || random_colname || ' FROM table';

FOR mviews IN EXECUTE sql LOOP
--possible to access 3rd column of mviews? something like mviews[3]?
END LOOP;

Regards,
Collin

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Albright 2007-05-02 19:26:23 Re: Possible to access value in RECORD without knowing column name?
Previous Message Collin Peters 2007-05-02 15:53:13 Re: Dynamic prepare possible in plpgsql?