Oracle EXECUTE IMMEDIATE into a cursor Oracle EXECUTE IMMEDIATE into a cursor oracle oracle

Oracle EXECUTE IMMEDIATE into a cursor


Assuming that your SQL is not longer than 32K (as @Tony Andrews hinted at), you should be able to use something like this:

declare   SQL_Text varchar2(32760) := 'select * from dual'; --your query goes here   cur sys_refcursor;begin   open cur for SQL_Text;end;

When working with Ref Cursors, open-for can be used directly, instead of execute immediate.