Entering content frame

SELECT Statement (select_statement) 

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

Syntax

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

query expression, order clause, update clause, lock option

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.

Depending on the search strategy, either all the rows in the result table are searched when the SELECT statement (select_statement) is executed and the result table is physically generated, or each next result table row is searched when a FETCH statement is executed, without being physically stored. 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:

ORDER clause

The ORDER clause specifies a sort sequence for a result table.

UPDATE clause

An UPDATE clause can only be specified for updateable result tables. For updateable 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 lines of each of the affected base tables using a LOCK statement.

LOCK option

The 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 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.

See also:

SELECT Statement (named_select_statement)

Leaving content frame