
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
116 lines
1.7 KiB
Plaintext
116 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
``++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)
|
|
|
|
=== Message
|
|
|
|
Refactor this statement to use "cursor%NOTFOUND".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 3 Feb 2015, 16:08:52 Ann Campbell wrote:
|
|
Hoping you can help me out with code samples [~dinesh.bolkensteyn]
|
|
|
|
=== on 8 May 2015, 15:12:40 Dinesh Bolkensteyn wrote:
|
|
\[~ann.campbell.2]
|
|
|
|
|
|
----
|
|
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;
|
|
/
|
|
----
|
|
|
|
->
|
|
|
|
|
|
----
|
|
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 -- Noncompliant
|
|
DBMS_OUTPUT.PUT_LINE('uh?');
|
|
ELSE
|
|
DBMS_OUTPUT.PUT_LINE('all good: ' || x);
|
|
END IF;
|
|
CLOSE c;
|
|
END;
|
|
/
|
|
----
|
|
|
|
endif::env-github,rspecator-view[]
|