In a plpgsql function, I have a variable of type record:
my_rec RECORD;
This record contains a row from an arbitrary table, so I do not know the columns before it is executed.
However, I do have the name of at least one of the columns available as a varchar.
The question is: How do I retrieve the value for a given column from my_rec?
Use
hstoreto work withrecords with dynamic columns inPL/PgSQLfunctions:hstoreis an extension, but it’s an extension that’s been bundled with PostgreSQL since 8.3 and has been installable usingCREATE EXTENSIONsince 9.1. The record-to-hstore conversion has been supported since something like 8.4 or 9.0.