rspec/rules/S2241/abap/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

51 lines
1.2 KiB
Plaintext

== Why is this an issue?
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
[source,abap]
----
OPEN CURSOR C FOR SELECT * FROM SBOOK WHERE CARRID = 'LH '. "NonCompliant
SELECT * FROM FLIGHTS WHERE FLIGHT_NUMBER = 'LH '."NonCompliant
----
=== Compliant solution
[source,abap]
----
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)
=== Message
Add an "ORDER BY" clause to this SQL "SELECT" statement.
'''
== Comments And Links
(visible only on this page)
=== relates to: S1592
=== relates to: S3270
=== on 2 Dec 2014, 14:41:56 Ann Campbell wrote:
\[~freddy.mallet] no code samples?
=== on 4 Dec 2014, 09:44:24 Freddy Mallet wrote:
Done [~ann.campbell.2]!
endif::env-github,rspecator-view[]