Is it possible to populate an array with dinamic query result?
I'm trying to get content of cursor c into the variable ap and the code i'm using is the following:
BEGIN
DECLARE
TYPE cur_typ IS REF CURSOR;
c cur_typ;
query_str VARCHAR2(1000);
job VARCHAR2(1000);
ap varchar2(30000);
aux varchar2(30000);
query varchar2(30000);
BEGIN
query_str := 'select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
query := 'CURSOR c IS'||' select ent_cod, ent_nom from grh_funcionarios where rownum < 10';
EXECUTE IMMEDIATE query;
OPEN c FOR query_str;
for ap in query_str loop
LOOP
FETCH c INTO ap;
EXIT WHEN c%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(aux);
END LOOP;
CLOSE c;
END;
END;