rspec/rules/S3613/cobol/rule.adoc

92 lines
1.7 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
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
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
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[]