How to return an empty cursor from a stored procedure?

I have an OUT parameter for a stored procedure as REF CURSOR . Based on a certain condition, I would like to either return a set of results (already implemented). But how do I return an empty cursor when a condition fails? Without involving an exception? Just insert pseudo code:

 IF condition = true THEN OPEN OUT_CUR FOR Select Some query ELSE Return empty OUT_CUR END IF 
+4
source share
1 answer

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; 
+13
source

Source: https://habr.com/ru/post/1438549/


All Articles