我有一些从存储函数中获取的变量。我想将它们作为存储过程中的游标返回。(原因是因为我想在 Jasper 报告中使用它们,而 Jasper 只允许带有游标输出的存储过程)
我的 PL/SQL 代码是:
procedure myprocedure (my_cursor OUT sys_refcursor) is
output1 TABLE1.FIELD1%TYPE;
output2 TABLE1.FIELD2%TYPE;
output3 TABLE2.FIELD1%TYPE;
output4 TABLE1.FIELD3%TYPE;
begin
IF NOT(package1.function1 (output1, output2, output3, output3))
THEN
output1 := NULL;
output2 := NULL;
output3 := NULL;
output4 := NULL;
END IF;
open my_cursor for
select :output1 as myoutput1, :output2 as myoutput2, :output3 as myoutput3, :output4 as myoutput4
from DUAL
end myprocedure;
我明白了PLS-00049: bad bind variable 'output1'
如何在游标中返回函数的结果?