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.
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
