rspec/rules/S3613/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

92 lines
1.7 KiB
Plaintext

== Why is this an issue?
There's no point in selecting columns in a cursor that aren't actually referenced in the relevant ``++FETCH++`` statement. Instead, either pare down the cursor to select only what you actually need, or ``++FETCH++`` the other columns.
=== Noncompliant code example
[source,cobol]
----
EXEC SQL
DECLARE C-SQL-CURSOR CURSOR
SELECT COLUMN1
,COLUMN2 -- Not fetched
,COLUMN3 -- Not fetched
FROM TBLWTABLE
WITH UR
END-EXEC.
EXEC SQL
FETCH C-SQL-CURSOR -- Noncompliant
INTO :H-COLUMN1
END-EXEC
----
=== Compliant solution
[source,cobol]
----
EXEC SQL
DECLARE C-SQL-CURSOR CURSOR
SELECT COLUMN1
,COLUMN2
,COLUMN3
FROM TBLWTABLE
WITH UR
END-EXEC.
EXEC SQL
FETCH C-SQL-CURSOR
INTO :H-COLUMN1, :H-COLUMN2, :H-COLUMN3
END-EXEC
----
or
[source,cobol]
----
EXEC SQL
DECLARE C-SQL-CURSOR CURSOR
SELECT COLUMN1
FROM TBLWTABLE
WITH UR
END-EXEC.
EXEC SQL
FETCH C-SQL-CURSOR
INTO :H-COLUMN1
END-EXEC
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use the other n column[s] selected in the cursor, or remove them from the cursor.
=== Highlighting
* primary: ``++INTO++`` + column list in ``++FETCH++`` statement
* secondary: ``++SELECT++`` + column list in cursor
'''
== Comments And Links
(visible only on this page)
=== relates to: S4103
endif::env-github,rspecator-view[]