An Open SQL SELECT
statement without an explicit ORDER BY
clause will retrieve rows in an unpredictable order. On
pool/cluster tables, the current implementation of Open SQL SELECT
returns the result set in the primary key order, but that’s not the
case for transparent tables. That’s why it’s safer to always use an ORDER BY
clause.
Noncompliant code example
OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH '. "NonCompliant
SELECT * FROM FLIGHTS WHERE FLIGHT_NUMBER = 'LH '."NonCompliant
Compliant solution
OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH '
ORDER BY PRIMARY KEY.
SELECT * FROM FLIGHTS WHERE FLIGHT_NUMBER = 'LH ' ORDER BY PRIMARY KEY.