rspec/rules/S2525/plsql/rule.adoc

66 lines
1009 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++cursor%NOTFOUND++`` is clearer and more readable than ``++NOT cursor%FOUND++``, and is preferred.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2021-04-28 16:49:39 +02:00
----
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2021-04-28 16:49:39 +02:00
----
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[]