rspec/rules/S2525/plsql/rule.adoc

54 lines
860 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
``++cursor%NOTFOUND++`` is clearer and more readable than ``++NOT cursor%FOUND++``, and is preferred.
2021-04-28 16:49:39 +02:00
== 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;
/
----
2021-04-28 16:49:39 +02:00
== 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;
/
----
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]