Rule Definition
The purpose of a Cobol SQL Cursor should be clearly specified by using the FOR clauses : READ ONLY, FETCH ONLY or UPDATE.
When the cursor will only be used to read data, you should always use FOR READ ONLY or FOR FETCH ONLY clauses. This will avoid table locking and allows other SQL statements to read from the same tables.
When the cursor will modify data, you should always use FOR UPDATE clause.
Remediation
Check the cursor and if so, add the expected FOR clause.
Violation Code Sample
EXEC SQL
DECLARE C_EMP CURSOR FOR
SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, SALARY
FROM DSN8C10.EMP
END-EXEC.
Fixed Code Sample
EXEC SQL
DECLARE C_EMP CURSOR FOR
SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, SALARY
FROM DSN8C10.EMP
FOR READ ONLY
END-EXEC.
Reference
IBM DB2 Guidelines for restricting SELECT statements: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.perf.doc/doc/c0005280.html
Related Technologies
Technical Criterion
Documentation - Style Conformity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.