Entering content frame

SELECT Statement (select_statement) Locate the document in its SAP Library structure

A SELECT statement (select_statement) defines and creates an unnamed result table).

Syntax

<select_statement> ::= <query_expression> [<order_clause>] [<update_clause>] [<lock_option>] [FOR REUSE]

Explanation

An OPEN CURSOR statement is not permitted for result tables created with this SELECT statement.

The SELECT statement (select_statement) is subject to the rules that were specified for the DECLARE CURSOR statement and those that were specified for the OPEN CURSOR statement.

The search strategy used determines how the search is carried out. When the SELECT statement is executed, the system searches for all the rows in the result table and generates the result table physically. When a FETCH statement is executed, the system searches for the next relevant row in the result table but does not store it physically. This must be taken into account for the time behavior of FETCH statements.

Updateable Result Table

A result table or the underlying base tables are updateable if the query statement satisfies the following conditions:

·        The QUERY statement comprises a DECLARE CURSOR statement.

·        The QUERY expression (query_expression) must only comprise one QUERY specification (query_spec).

·        Only one base table or one updateable view table may be specified in the FROM clause of the QUERY specification.

·        The key word DISTINCT or a GROUP or HAVING clause must not be specified.

·        Expressions must not contain a set function (set_function_spec).

ORDER Clause

The ORDER clause (order_clause) specifies a sort sequence for a result table.

UPDATE Clause

An UPDATE clause (update_clause) can only be specified for updateable result tables. For updatable result tables, a position within a particular result table always corresponds to a position in the underlying tables and thus, ultimately, to a position in one or more base tables.

If an UPDATE clause was specified, the base tables can be updated using the position in the result table (CURRENT OF <result_table_name>) by means of an UPDATE statement or a DELETE statement. A lock can be requested for the affected rows of each of the affected base tables using a LOCK statement.

LOCK Option

The LOCK option (lock_option) determines which locks are to be set on the read rows.

FOR REUSE

If the result table is to be specified in the from clause of a subsequent QUERY statement, the table should be specified with the FOR REUSE keywords. If FOR REUSE is not specified, the reusability of the result table depends on internal system strategies.

Since specifying FOR REUSE increases the response times of some query statements, it should only be specified if it is required to reuse the result table.

 

Leaving content frame