How do I access a cursor's column using a string column?
Example:
CREATE FUNCTION write_html_select(items cursor, data_value_field text,
data_text_field text)
AS
$$
DECLARE r RECORD;
html TEXT;
BEGIN
FOR r in items LOOP
html = "<option value=" || r[data_value_field] || "/>";
END LOOP;
RETURN html;
END;
$$
LANGUAGE plpgsql;
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?