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

----
      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

----
      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

----
      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[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
