rspec/rules/S2241/abap/rule.adoc

39 lines
1.0 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,abap]
2021-04-28 16:49:39 +02:00
----
OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH '. "NonCompliant
SELECT * FROM FLIGHTS WHERE FLIGHT_NUMBER = 'LH '."NonCompliant
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,abap]
2021-04-28 16:49:39 +02:00
----
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[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]