rspec/rules/S1732/cobol/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
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.
2023-05-25 14:18:12 +02:00

49 lines
1.2 KiB
Plaintext

== Why is this an issue?
Explicitly defining a cursor as read-only can improve performance by avoiding table locking. This allows other SQL requests to execute in parallel. Therefore when a cursor will only be used to read data, without modifying anything, the ``++FOR READ ONLY++`` clause or its synonyn, ``++FOR FETCH ONLY++``, should be used.
Conversely when a cursor will modify data, that too should be specified using the ``++FOR UPDATE++`` clause.
In short, it's better to always explicitly define the purpose of the cursor with help of the ``++FOR READ ONLY++``, ``++FOR FETCH ONLY++`` or ``++FOR UPDATE++`` clauses.
=== Noncompliant code example
[source,cobol]
----
EXEC SQL DECLARE CMAJ_0A CURSOR
FOR SELECT C_BQ
FROM S1ORDCOU
WHERE C_BQ = :TORD-C-BQ
END-EXEC
----
=== Compliant solution
[source,cobol]
----
EXEC SQL DECLARE CMAJ_0A CURSOR
FOR SELECT C_BQ
FROM S1ORDCOU
WHERE C_BQ = :TORD-C-BQ
FOR READ ONLY
END-EXEC
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Explicitly specify whether the "XXXX" cursor is read-only or not.
endif::env-github,rspecator-view[]