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