Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Reads →  SELECT clauses 

SELECT - abap_options

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


 ... [BYPASSING BUFFER] 
    [CONNECTION con|(con_syntax)] ...

Extras

1.... BYPASSING BUFFER

2.... CONNECTION con|(con_syntax)

Effect

These ABAP-specific additions of a main query of a standalone SELECT statement or WITH statement specify whether table buffering is bypassed, and define the database connection.

If the INTO clause is specified as last clause of the SELECT statement, the additions must follow after the INTO clause. Otherwise, they can also be specified after the SELECT clause or after the FROM clause.

Addition 1

... BYPASSING BUFFER

Effect

This addition forces the SELECT statement to bypass the table buffering of buffered database tables or views. Any buffers on the current AS Instance are not accessed and the database is accessed directly instead.


Notes

  • The addition BYPASSING BUFFER can be used if it is vital that the current data is accessed for a buffered table instead of the buffer.
  • The addition BYPASSING BUFFER can be specified for unbuffered database tables or views in which case it describes the regular behavior.
  • The addition BYPASSING BUFFER does not ensure that data in an internal table is transported to the database when reads are performed on the table using FROM ... @itab.

Example

Accesses the most current data of the fully buffered database table SPFLI.

SELECT * 
       FROM spfli 
       INTO TABLE @DATA(result) 
       BYPASSING BUFFER. 

Addition 2

... 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
Specified directly and statically as con.
  • (con_syntax)
Specified as the content of a parenthesized data object con_syntax of type c or string. The following can be specified for con_syntax:
  • Literal or constants

    If the data object con_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 object con_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 ABAP SQL statement uses the secondary connection to access the database schema of the database user of the secondary database that is defined for the secondary connection in the database table DBCON. All subsequent ABAP SQL statements in the same internal session (for which the same secondary connection is specified) use the active connection.
  • 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,
The ABAP SQL statement uses the standard connection to access the ABAP database schema of the standard database. All subsequent ABAP SQL statements in the same internal session (for which the same service connection is specified) use the active connection.
  • 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 using AS.

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.
  • The addition CONNECTION cannot be used together with the addition WITH HOLD of the statement OPEN CURSOR.

Example

Reads data using a service connection to the standard database.

SELECT * 
       FROM scarr 
       INTO TABLE @DATA(itab) 
       CONNECTION r/3*my_conn. 

cl_demo_output=>display( itab ).