Non-checked SQLCODE after &SQL

objectscriptQuality release 
2.1.0
Id 
OS0090
Rule type 
Code Smell
Severity 

Major

Major
SQALE characteristic 
  • Reliability
    • Data
Tags 
probable-bug, reliability
Remediation function 
Constant/issue
Remediation cost 
1h

SQL must be checked after each execution of a &SQL() statement.

Non-compliant code

method runsql()
{
    &SQL(SELECT Val1, Val2
                INTO :val1, :val2
                FROM Table
                WHERE Val1='SomeCondition')

    WRITE !,"Name is: ",val1

}
    

Compliant code

method runsql()
{
    &SQL(SELECT Val1, Val2
                INTO :val1, :val2
                FROM Table
                WHERE Val1='SomeCondition')

    IF SQLCODE=0 {
      WRITE !,"Name is: ",val1
      WRITE !,"State is: ",val2
   }
}