Using PostgreSQL, column values from a table for 1st record are stored in a record variable. for example: let the variable be:
recordvar
and different columns be:
name,id,gender,age
recordvar.name
But I want to retrieve that colum value like
var =name
then
recordvar.var
How can I do this? I don't want to use hstore.
Here is the sample 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$
rec_room.de_name is not working