Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is it possible to populate an array with dinamic query result?

PedroMendezDec 31 2008 — edited Dec 31 2008
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;
This post has been answered by Satyaki_De on Dec 31 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2009
Added on Dec 31 2008
10 comments
932 views