Oracle EXECUTE IMMEDIATE插入游标 [英] Oracle EXECUTE IMMEDIATE into a cursor
本文介绍了Oracle EXECUTE IMMEDIATE插入游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个存储过程,该存储过程使用EXECUTE IMMEDIATE
命令执行一个很长的字符串.如何支持一个很长的字符串并将数据返回到refcursor中?
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 refcursor?
推荐答案
假定您的SQL长度不超过32K(如@Tony Andrews所暗示的),则您应该可以使用以下代码:
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;
使用参考光标时,可以直接使用open-for
代替execute immediate
.
When working with Ref Cursors, open-for
can be used directly, instead of execute immediate
.
这篇关于Oracle EXECUTE IMMEDIATE插入游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文