Select specific column from cursor record variable in PostgreSQL
<p>Using PostgreSQL, column values from a table for 1st record are stored in a record variable. for example: let the variable be:</p>

<pre><code>recordvar
</code></pre>

<p>and different columns be:</p>

<pre><code>name,id,gender,age
recordvar.name
</code></pre>

<p>But I want to retrieve that colum value like</p>

<pre><code>var =name
</code></pre>

<p>then</p>

<pre><code>recordvar.var
</code></pre>

<p>How can I do this? I don't want to use hstore.</p>

<p>Here is the sample code</p>

<pre><code>CREATE OR REPLACE FUNCTION public.get_all_rooms()
  RETURNS text AS
$BODY$
DECLARE 

 total integer;
 titles TEXT DEFAULT '';
 rec_croom   RECORD;
 rec_delement integer;
 rec_locations   integer;
 rec_dname   varchar;
 starts_with text = NULL;
 ends_with text = NULL;
 de_name   varchar;
 --de_array   integer[];
 de_arr_val integer;
 sql text;
 cur_croom CURSOR
 FOR SELECT *
FROM  public.tmp_all_controlroom_2;

BEGIN

 -- Open the cursor
   OPEN cur_croom;

   LOOP
    -- fetch row into the film
      FETCH cur_croom INTO rec_croom;
    -- exit when no more row to fetch
      EXIT WHEN NOT FOUND;


       SELECT locationid INTO rec_locations FROM location WHERE locationcode = rec_croom.location_code;



     FOR de_arr_val in select deid from dsmtbl WHERE dsid=74
      LOOP


    select name INTO de_name from tab1 where deid=de_arr_val;

        INSERT INTO datavalue (a,  b, c, d, e, value)
    VALUES(de_arr_val, 1, rec_croom.cday , rec_locations, 3154, rec_room.de_name);
    END LOOP;     

   END LOOP;

   -- Close the cursor
   CLOSE cur_croom;

   RETURN titles;
END; $BODY$
</code></pre>

<p>rec_room.de_name is not working</p>