oracle 如何从存储过程返回空游标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12792768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to return a empty cursor from a stored procedure?
提问by KeenUser
I have OUT
parameter of a stored procedure as a REF CURSOR
. Based on a particular condition, I would want to either return a result set (already implemented). But how do I return an empty cursor when the condition fails? Without raising an exception? Just pasting pseudo code:
我有OUT
一个存储过程的参数作为REF CURSOR
. 根据特定条件,我想返回一个结果集(已实现)。但是当条件失败时我如何返回一个空游标?不抛出异常?只是粘贴伪代码:
IF condition = true THEN
OPEN OUT_CUR FOR
Select Some query
ELSE
Return empty OUT_CUR
END IF
回答by Satya
you can try this
你可以试试这个
IF condition = true THEN
OPEN OUT_CUR FOR
Select Some query;
ELSE
OPEN OUT_CUR FOR
Select * from mtable where 1=2;
END IF
return OUT_CUR;
回答by Vusal Hasanli
IF condition = true THEN
OPEN OUT_CUR FOR
Select Some query
ELSE
OPEN OUT_CUR FOR select * from unnest(array[1,2]) arr where false
END IF