2023-05-03 11:06:20 +02:00
== 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.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== 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
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== 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
----
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== 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
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== relates to: S4103
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]