rspec/rules/S2525/plsql/rule.adoc
2022-02-04 16:28:24 +00:00

64 lines
981 B
Plaintext

``++cursor%NOTFOUND++`` is clearer and more readable than ``++NOT cursor%FOUND++``, and is preferred.
== Noncompliant Code Example
[source,sql]
----
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
[source,sql]
----
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[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]