R302 – Use a SELECT+THE in preference to a while loop (WMB)

Use SELECT + THE in preference to a WHILE loop where possible when searching through an internal table of values.

For example – the following has a loop   SET intItems = CARDINALITY(inRef.Order_line[]);
  SET intLoop = 1;

  –Below WHILE loop can be replaced with SELECT THE
  X: WHILE intLoop <= intItems DO
    IF TRIM(inRef.Order_line[intLoop].MOD) = 'TC' THEN
      SET outRef.Order_type = 'PRE_PAID';
      LEAVE X;
    END IF;
    SET intLoop = intLoop + 1;

Could be replaced by this code   SET outRef.Order_type = THE (
      FROM inRef.Order_line[] AS orderLineItem
        WHERE TRIM(orderLineItem.MOD) = ‘TC’