ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Write Accesses
INSERT, UPDATE, MODIFY, DELETE dbtab - connection
Other versions:
7.31 | 7.40 | 7.54
Syntax
... CONNECTION con|(con_syntax) ...
Effect
The ABAP SQL statement is executed on the specified database connection. The database connection can be specified as follows:
-
con
con
.
-
(con_syntax)
con_syntax
of type
c
or string
. The following can be specified for con_syntax
:
- Literal or constants
If the data objectcon_syntax
is specified as a character literal or as a constant, it can be evaluated statically and the database connection is identified as the used object.
- Variable
If the data objectcon_syntax
is specified as a variable, it is specified only dynamically and the content is not evaluated statically.
The following can be specified for con
or in con_syntax
(and transformed to uppercase letters internally):
-
default
specified statically or DEFAULT specified dynamically for the standard connection of the current work process. The ABAP SQL statement uses the standard connection to access the ABAP database schema of the standard database. -
The name of secondary
connection specified statically or dynamically. The name must exist in the column CON_NAME of the database table DBCON. The following applies to the secondary connection:
- It is used in its current database LUW if already open actively in the current internal session.
- If it is not yet open actively in the current internal session, it is either opened for the current work process or (if already open) it is reused and set to an active state,
-
The name of a service connection to the
standard database specified
statically or dynamically. The name of a service connection must consist of the prefix R/3*
followed by any 26 alphanumeric characters (in uppercase). The following applies to the service connection:
- It is used in its current database LUW if already open actively in the current internal session.
- If it is not yet open actively in the current internal session, it is either opened for the current work process or (if already open) it is reused and set to an active state,
-
A name (in uppercase letters) granted for a secondary connection or service connection by the addition
AS
of the static Native SQL statement CONNECT TO. The same rules apply here as to directly specified secondary connections or service connections. It should be noted, however, that a connection with a name of this kind is a standalone database connection that can exist in parallel with a connection without a name defined usingAS
.
A database connection is not evaluated until runtime, regardless of whether it is specified statically or dynamically, and any unknown database connections produce the runtime error DBSQL_UNKNOWN_CONNECTION.
The database tables or views specified in the current ABAP SQL statement must be active in ABAP Dictionary in the current AS ABAP regardless of the specified database connection. In a secondary database, an identically named and usable object with a suitable structure must exist for each database table or view specified in the current ABAP SQL statement. If not, an exception is raised.
Notes
- Detailed information about database connections can be found here.
- Any ABAP SQL statement that uses the standard connection accesses the ABAP database schema only.
- Secondary database connections can be used to access all views that can be accessed using ABAP SQL, including database views, projection views, external views, and non-abstract CDS entities. CDS views should be specified using the name of the CDS entity, since CDS database views are an obsolete way of accessing views.
- The type of a database object specified in an ABAP SQL statement does not necessarily need to match the type of the database object with the same name in the secondary database. For example, a view with the same name in the secondary database can be accessed by specifying a database table (or a database table by specifying a view) if they have the same structure.
- Unlike in ABAP SQL, any database connections specified in Native SQL and AMDP are case-sensitive. To access a database connection activated in ABAP SQL in Native SQL or AMDP, the connection must be specified in uppercase letters. Conversely, an ABAP SQL statement cannot use a database connection activated using Native SQL AMDP if its name contains lowercase letters.
-
The addition
CONNECTION
bypasses table buffering.
Example
Deletes all data in a database table using a service connection to the standard database.
DELETE FROM demo_expressions CONNECTION r/3*my_conn.