Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Writes →  INSERT dbtab 

INSERT dbtab - target

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... dbtab|view|(target_syntax) [USING CLIENT clnt] | [CLIENT SPECIFIED] 
                               [CONNECTION con|(con_syntax)] ...

Alternatives

1. ... dbtab|view
2. ... (target_syntax)

Extras

1. ... USING CLIENT
2. ... CLIENT SPECIFIED

Effect

The entries in target determine, statically or dynamically, which database table or which view is accessed, and control client handling.

Alternative 1

... dbtab|view

Effect

dbtab expects a database table or a view and a classic view defined in ABAP Dictionary.

Only views that refer to a single database table, and whose status in ABAP Dictionary permits changes can be specified. No external views or CDS views can be specified.

Alternative 2

... (target_syntax)

Effect

Instead of specifying an object statically, a parenthesized data object target_syntax can be specified that must contain the name of the database table or the view when the statement is executed. A character-like data object or a standard table without secondary table keys and with a character-like row type can be specified for the data object target_syntax. The syntax in target_syntax is not case-sensitive, as in ABAP Editor.

Security Note

If used wrongly, dynamic programming techniques can present a serious security risk. Any dynamic content that is passed to a program from the outside must be checked thoroughly or escaped before being used in dynamic statements. This can be done using the system class CL_ABAP_DYN_PRG or the predefined function escape. See SQL Injections Using Dynamic Tokens.


Note

When specified dynamically, Open SQL statements can contain the comment characters * and " as follows:

  • In a dynamic token specified as a character-like data object, all content is ignored from the first comment character ".
  • In a dynamic token specified as an internal table, all rows are ignored that start with the comment character *. In the row, all content is ignored from the first comment character ".

Addition 1

... USING CLIENT clnt

Effect

This addition modifies automatic client handling in Open SQL so that the client ID from clnt is used instead of the current client ID. The ABAP runtime environment passes the ID of the client specified in clnt to the database system, and not the ID of the current client or the client specified in source.

clnt expects a data object of the type c with length 3 and containing a client ID. The addition can only be used when changing a client-specific table or a view and not together with the addition CLIENT SPECIFIED. If specified, the system field sy-mandt would be ignored and cannot be specified directly for clnt.


Notes

  • If the addition USING CLIENT is used, the statement Open-SQL functions as if the current user were logged on with the client ID specified in clnt.
  • If clnt contains a client ID for a nonexistent client, the SQL statement is executed with this ID and has no effect as a result.
  • The addition USING CLIENT is not allowed in the obsolete short forms.
  • When the addition USING CLIENT, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.
  • Since each client represents a complete unit, automatic client handling should never be switched in application programs.
  • If access to the data of a different client is required, USING CLIENT should be used instead of CLIENT SPECIFIED, since in this case all necessary conditions are set implicitly.
  • See also the associated security note and the programming guideline.

Addition 2

... CLIENT SPECIFIED

Effect

This addition deactivates automatic client handling in Open SQL. If the addition CLIENT SPECIFIED is used, the client ID specified in source is respected. Without the addition CLIENT SPECIFIED, the ABAP runtime environment does not pass the client ID specified in source to the database system, but passes the ID of the current client instead.


Notes

  • Since each client represents a complete unit, automatic client handling should never be turned off in application programs.
  • If data has to be accessed in a different client, USING CLIENT should be used instead of the addition CLIENT SPECIFIED, since all necessary conditions are set implicitly and accessing client-specific CDS views is more simple.
  • See also the associated security note and the programming guideline.


This translation does not reflect the current version of the documentation.