== Why is this an issue?

To improve source code readability and reusability, SQL operations should be located in dedicated procedures (sections or paragraphs) and should not be mixed with other SQL requests.


=== Noncompliant code example

[source,cobol]
----
MAIN_PARAGRAPH.
  ...
  LOAD_SALARY.
  ...

LOAD_SALARY.
  EXEC SQL CONNECT :UID IDENTIFIED BY :PASS END-EXEC.
  EXEC SQL USE tempdb END-EXEC.   *< Noncompliant
  EXEC SQL
    SELECT   SALARY  
        INTO  :HV-SALARY
      FROM EMPLOYEE
        WHERE EMPNAME = 'XXXXXXX'
  END-EXEC.
  EXIT.
----


=== Compliant solution

[source,cobol]
----
MAIN_PARAGRAPH.
  ...
  CONNECT_TO_DB.
  USE_TMP_DB_SCHEMA.
  ...
  LOAD_SALARY.
  ...
CONNECT_TO_DB.
  EXEC SQL CONNECT :UID IDENTIFIED BY :PASS END-EXEC.
  EXIT.

USE_TMP_DB_SCHEMA.
  EXEC SQL USE tempdb END-EXEC.
  EXIT.

LOAD_SALARY.
  EXEC SQL
    SELECT   SALARY  
        INTO  :HV-SALARY
      FROM EMPLOYEE
        WHERE EMPNAME = 'XXXXXXX'
  END-EXEC.
  EXIT
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Split the "XXXX" [paragraph|module] to perform at most one SQL operation.


'''
== Comments And Links
(visible only on this page)

=== on 22 Jan 2014, 16:43:43 Dinesh Bolkensteyn wrote:
List of IO statements: read, rewrite, start, write, delete, sqlSelectStatement

endif::env-github,rspecator-view[]
