plpgsql - accessing field in RECORD variable by text variables

From: "Damjan Pipan" <damjan(dot)pipan(at)siol(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: plpgsql - accessing field in RECORD variable by text variables
Date: 2002-11-19 15:02:07
Message-ID: 007001c28fdc$c637fbd0$6700010a@valhala
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I have the following code which does not work:

CREATE OR REPLACE FUNCTION td1(integer) RETURNS REFCURSOR AS '
DECLARE
r article%ROWTYPE;
BEGIN

SELECT INTO r * FROM article WHERE key = $1;
a := ''some_other_field'';
RAISE NOTICE ''%'', r.a;
END;
' LANGUAGE 'plpgsql';

SELECT td1(229);

I would like to access RECORD type variables fields by assigning field (attribute) name
to some text variable and then access the field in RECORD which has the same name.

Is this possible in plpgsql?

I can not use the dot notation (fully qualification). What I would like to do
is some automatic field copying from another table to table being updated
and that this field copying can be managed in DB by changing some record in
my meta table.

Damjan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-11-19 15:47:06 Re: plpgsql - accessing field in RECORD variable by text variables
Previous Message Damjan Pipan 2002-11-19 14:59:22 plpgsql - accessing field in RECORD variable by text variables