I am new to PL/SQL and I just got to cursors in my learning process. I've been seeing stored procedure parameters with type OUT SYS_REFCURSOR
which, as far as I understand, its purpose is to 'return data' just like a pointer in C language. I been wondering who is going to close such SYS_REFCURSOR
parameter if the procedure has to open it and can't close it? (If the procedure closes the out OUT SYS_REFCURSOR
then there will not be any data to return).
Also, I think, it is bad design to rely on external functions other than the stored procedure that contains OUT SYS_REFCURSOR
parameter to close the cursor. Is there a way I can return a table from a stored procedure without using cursors?