ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP - Database Accesses → ADBC - ABAP Database Connectivity → CL_SQL_STATEMENT - Execution of SQL Statements
DDL and DML Statements
The CL_SQL_STATEMENT class provides the following instance methods for executing DDL and DML statements;
- EXECUTE_DDL
- EXECUTE_UPDATE
The first method is for DDL statements such as CREATE
, DROP
,
or ALTER
, whereas the second method is for the DML statements INSERT
, UPDATE
, and DELETE
.
Both methods have an obligatory input parameter STATEMENT of type string
that must be passed to a syntactically correct SQL statement. The method EXECUTE_UPDATE also has a return value, ROWS_PROCESSED, that returns the number of table rows processed.
In DML statements values that are passed to the database system can be parameterized using the placeholder
?
. When the statement is executed, compatible ABAP Objects must be bound to these parameters. This binding takes place using the method
- SET_PARAM
of the CL_SQL_STATEMENT class. This method expects a reference to a data object and must be called once
for every parameter ?
before the SQL statement is executed. The order of
the calls determines the assignment to the placeholders from left to right. After all SQL statements are executed, the binding is removed.
Other versions: 7.31 | 7.40 | 7.54
Notes
- The two methods EXECUTE_DDL and EXECUTE_UPDATE are technically different only in that EXECUTE_UPDATE returns the number of rows processed. However, for reasons of readability of the program it is advisable to only use the methods as intended.
- A data reference to an indicator variable of the predefined type INT2 in ABAP Dictionary can be passed to the optional input parameter IND_REF of the method SET_PARAM. If the value of this indicator variable is -1, the value 0 of a parameter on the database is converted to a null value.
Examples
See