pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Collin Peters <cadiolis@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Possible to access value in RECORD without knowing column name?
Date: Wed, 2 May 2007 12:17:08 -0700
Message-ID: <df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com>
Permalink:  ../df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com/
Also on:    postgresql.org/message-id/df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cadiolis@gmail.com
  Subject: Re: Possible to access value in RECORD without knowing column name?
  In-Reply-To: <df01c91b0705021217j2fc03527pc06339c954ab5ffd@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox