Forum OpenACS Development: Response to SQL functions returning rowsets (of one type)

Select into doesn't work in dynamic queries, but there is a work-around:

create function zztest(text, text) returns integer as '
declare
           table_name 	alias for $1;
           column_name 	alias for $2;
           dyn_query 	varchar(4000);
           v_rec	record;
begin
	dyn_query := ''select sum('' || quote_ident(column_name) || '') as return_value from '' || quote_ident(table_name);
	FOR v_rec in EXECUTE dyn_query LOOP
		return v_rec.return_value;
	END LOOP;
END;