My database is PostgreSQL 9.3.5.
I have a dynamic query which will be populated with a different number of columns for each run. For that we have to capture that runtime structure. we thought refcursor
structure is okay. But how to declare?
Example:
DECLARE
curs1 refcursor;
v_cols curs1%ROWTYPE;----> It is giving us error
BEGIN
OPEN curs1 FOR EXECUTE 'SELECT * FROM '|| tablename||'';
LOOP
FETCH curs1 INTO ....; --->Here how to capture the data
EXIT WHEN NOT FOUND;
END LOOP;
CLOSE curs1;
END;