Please disregard my other message. I didn't get what you are trying to
do at first.
You can do this with dynamic SQL: Look at 38.5.4. Executing Dynamic
Commands (http://www.postgresql.org/docs/current/static/plpgsql-
statements.html).
I guess something like
EXECUTE 'SELECT tmprec.group' || i INTO value
will work in a loop. Didn't try it though.
regards,
Ivan Pavlov