If every WHEN
test of a SELECT
statement fails, an ERROR
condition is raised if the OTHERWISE
statement is omitted. This can lead to the unexpected termination of the program.
Noncompliant code example
foo: proc options(main);
declare i fixed decimal init (42);
select (i); /* Non-Compliant - SELECT without OTHERWISE statement */
when (0) put list ('i = 0');
when (1) put list ('i = 1');
end;
put list ('Continuation'); /* This statement will not be executed */
end;
Compliant solution
foo: proc options(main);
declare i fixed decimal init (42);
select (i); /* Compliant */
when (0) put list ('i = 0');
when (1) put list ('i = 1');
otherwise; /* No operation */
end;
put list ('Continuation'); /* This statement will be executed */
end;