Oracle EXECUTE IMMEDIATE into a cursor

后端 未结 1 1852
半阙折子戏
半阙折子戏 2021-01-12 04:32

I have a stored procedure which used the EXECUTE IMMEDIATE command to execute a very long string. How do I support a very long string and return the data into a

相关标签:
1条回答
  • 2021-01-12 05:11

    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.

    0 讨论(0)
提交回复
热议问题