2015-03-10 20:56 GMT+01:00 inspector morse <inspectormorse86@xxxxxxxxx>:
As you can see, I want to access RECORD r's columns by a STRING column name value (data_value_field etc)....is there anyway to do this?LANGUAGE plpgsql;$$ASCREATE FUNCTION write_html_select(items cursor, data_value_field text, data_text_field text)How do I access a cursor's column using a string column?Example:DECLARE r RECORD;html TEXT;BEGINFOR r in items LOOPhtml = "<option value=" || r[data_value_field] || "/>";END LOOP;RETURN html;END;
$$
you can translate record to Hstore type and then you can take a value by dynamic name. Usual older solution was using plperl or plpython.
Regards
Pavel