Ansicht
Dokumentation

ABENCL_SQL_CONNECTION - CL SQL CONNECTION

ABENCL_SQL_CONNECTION - CL SQL CONNECTION

BAL Application Log Documentation   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

- CL_SQL_CONNECTION

The SQL statements that are represented by objects of the CL_SQL_STATEMENT and CL_SQL_PREPARED_STATEMENT classes work by default with the standard AS ABAP database. The following class can be used to enable additional database connections or to make settings for database connections, including the standard connection:

The following can be passed to the method GET_ABAP_CONNECTION of this class:

All of these instances are case-sensitive. The method attempts to activate the corresponding connection or continue using it and, if successful, creates an instance of CL_SQL_CONNECTION as a connection object and returns the corresponding reference.

A further method GET_CONNECTION has the additional parameter SHARABLE, which can be used to share a secondary connection or service connection with , Native SQL, and AMDP.

  • If the value abap_true is passed to the parameter, GET_CONNECTION works like GET_ABAP_CONNECTION and the connection is shared.
  • If the value abap_false (default) is passed to the parameter, the secondary connection or service connection can be used exclusively by using the connection object.

References to instances of CL_SQL_CONNECTION can be passed to the parameter CON_REF of the instance constructor of CL_SQL_STATEMENT or CL_SQL_PREPARED_STATEMENT. Instances created in this way execute their SQL statements on the database connection represented by the instance of CL_SQL_CONNECTION.

The instance method CLOSE of CL_SQL_CONNECTION closes the current secondary connection or service connection. All database changes not yet committed using a database commit are discarded here. The instance can no longer be used after this and statements that are already linked with the connection become invalid. CLOSE is ignored in instances that represent the standard connection.

To handle database LUWs using ADBC, the class CL_SQL_CONNECTION contains the methods COMMIT and ROLLBACK, which raise a database commit or database rollback respectively. Furthermore, CL_SQL_CONNECTION contains methods for setting the transaction behavior of the current database connection. When an SAP HANA database is accessed, these methods must be used instead of the corresponding SQL SET TRANSACTION statements.

Notes

  • To create a connection object for the standard connection, an instance of CL_SQL_CONNECTION can be created directly using CREATE OBJECT or the instance operator NEW instead of calling the method GET_ABAP_CONNECTION with the value DEFAULT.

Example

Specification of a service connection to the standard database for a prepared statement.






CPI1466 during Backup   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 5148 Date: 20240426 Time: 175133     sap01-206 ( 77 ms )