Sonali Gupta
Sonali Gupta

Reputation: 514

Check SYS_REFCURSOR is null or not

I am working with stored procedure for the first time and I have a stored proc which does some checking to set a SYS_REFCURSOR as NULL.

create or replace PROCEDURE "proc"
(
    tableRec OUT SYS_REFCURSOR
)
.
.
BEGIN
.
.
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
        tableRec := NULL;
    END;

Once this is run, I need to check if tableRec was null or not before running another if loop. I tried as below

BEGIN
    if tableRec = NULL then

but this doesnt work. Elsewhere this is possible to check if a number say itemCount, is 0 by writing

if itemCount = 0 then

Can anyone explain how to achieve this for SYS_REFCURSOR and why it works for number and not for it. It is not about checking if the SYS_REFCURSOR is empty(because I found information about it on internet) or not but make use of the fact that is it set as NULL

Upvotes: 0

Views: 576

Answers (1)

VBoka
VBoka

Reputation: 9083

You need to use IS NULL to check if something is null ?

create or replace PROCEDURE proc (tableRec OUT SYS_REFCURSOR)
as
BEGIN

if tableRec is NULL then
    null;
end if;

END;
/

DEMO

Upvotes: 1

Related Questions