rspec/rules/S1506/abap/rule.adoc

54 lines
1.5 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
The ``++EXEC SQL ... END-EXEC++`` statement can be used to embed Native SQL statically in ABAP programs.
According to the SAP documentation:
____
Alongside ADBC, it is also possible to embed Native SQL statically between ``++EXEC SQL++`` and ``++ENDEXEC++`` in ABAP programs. The recommendation, however, is to use ADBC. While the static embedding of Native SQL offers exclusively static access to the Native SQL interface, ADBC makes modern object-orientated and dynamic access possible. New developments and improvements, such as optimized performance using bulk access across internal tables, are now made only for ADBC.
The existing static embedding of Native SQL statements is still supported but should no longer be used in new programs.
____
=== 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
----
EXEC SQL.
CREATE TABLE abap_docu_demo_mytab (
val1 char(10) NOT NULL,
val2 char(10) NOT NULL,
PRIMARY KEY (val1) )
ENDEXEC.
----
=== 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
----
NEW cl_sql_statement( )->execute_ddl(
`CREATE TABLE ` && dbname &&
`( val1 char(10) NOT NULL,` &&
` val2 char(10) NOT NULL,` &&
` PRIMARY KEY (val1) )` ).
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
If there is no other option than using native SQL, at least the ADBC API should be used.
endif::env-github,rspecator-view[]