rspec/rules/S1754/rpg/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

48 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

== Why is this an issue?
``++SELECT++`` and ``++OMIT++`` allow you to choose records from a logical file based on the values of specific fields. SQL views allow you to make the same distinctions, but their use is more efficient, and easier to read and understand. Therefore views are preferred over ``++SELECT++`` and ``++OMIT++`` statements.
=== Noncompliant code example
[source,rpg]
----
Index: SKCOU03
*************** Beginning of data *************************************
A R SKCOU TEXT('Coupon Rate Details')
A PFILE(SKCOUP)
A K COUASS
A K COUEFF DESCEND
A S COUSTS COMP(EQ 'L')
A S COUSTS COMP(EQ 'X')
****************** End of data ***************************************
----
=== Compliant solution
[source,rpg]
----
CREATE VIEW SKCOU03 AS
SELECT A.COUFLD1, A.COUASS, A.COUEFF, A.COUSTS, A.COUFLD4
FROM SKCOUP A
where
A.COUSTS = L OR A.COUSTS=X
Order by A.COUASS, A.COUEFF desc
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use a SQL view instead
endif::env-github,rspecator-view[]