Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个存储过程,它使用EXECUTE IMMEDIATE命令来执行一个很长的字符串。我如何支持很长的字符串并将数据返回到 refcursor?
EXECUTE IMMEDIATE
假设您的 SQL 不超过 32K(正如@Tony Andrews 暗示的那样),您应该能够使用这样的东西:
declare SQL_Text varchar2(32760) := 'select * from dual'; --your query goes here cur sys_refcursor; begin open cur for SQL_Text; end;
使用 Ref Cursors 时,open-for可以直接使用,而不是execute immediate.
open-for
execute immediate