cursor%NOTFOUND
is clearer and more readable than NOT cursor%FOUND
, and is preferred.
Noncompliant code example
SET SERVEROUTPUT ON
DECLARE
CURSOR c IS SELECT DUMMY FROM DUAL;
x VARCHAR2(1);
BEGIN
OPEN c;
FETCH c INTO x;
IF NOT c%FOUND THEN -- Noncompliant
DBMS_OUTPUT.PUT_LINE('uh?');
ELSE
DBMS_OUTPUT.PUT_LINE('all good: ' || x);
END IF;
CLOSE c;
END;
/
Compliant solution
SET SERVEROUTPUT ON
DECLARE
CURSOR c IS SELECT DUMMY FROM DUAL;
x VARCHAR2(1);
BEGIN
OPEN c;
FETCH c INTO x;
IF c%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE('uh?');
ELSE
DBMS_OUTPUT.PUT_LINE('all good: ' || x);
END IF;
CLOSE c;
END;
/