rspec/rules/S1473/cobol/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

77 lines
1.4 KiB
Plaintext

== 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[]