Dynamically access to field on a RECORD variable

From: Ricardo Vaz Mannrich <rvm_l1(at)silcom(dot)com(dot)br>
To: pgsql-general(at)postgresql(dot)org
Subject: Dynamically access to field on a RECORD variable
Date: 2005-05-03 14:04:03
Message-ID: 1115129042.25781.16.camel@curitiba.silcom
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Supose I have this function

CREATE OR REPLACE my_func(TEXT) RETURNS text AS '
DECLARE
var_name ALIAS FOR $1;
rec RECORD;
BEGIN
SELECT * INTO rec FROM my_table WHERE my_key = 1;
-- Here is my problem
RETURN rec.var_name;
END;
' LANGUAGE plpgsql;

SELECT my_func('my_field');

I want the return row in the function executes as:

RETURN rec.my_field;

Is it possible?

Thank you.

--
Ricardo Vaz Mannrich <rvm_l1(at)silcom(dot)com(dot)br>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2005-05-03 14:09:30 Re: some questions : psql
Previous Message Alexandre Biancalana 2005-05-03 13:39:58 postgresql 8 abort with signal 10