A QUERY statement (query_statement) specifies a result table that can be ordered. There are different ways of formulating a QUERY statement.
<query_statement> ::= <declare_cursor_statement>
| <recursive_declare_cursor_statement>
| <select_statement>
A QUERY statement generates a named/unnamed result table. In contrast to a named result table, an unnamed result table cannot be specified in a FROM clause or in CURRENT OF <result_table_name> of a subsequent SQL statement.
A distinction is made between the following QUERY statements:
Basic types of QUERY statement |
|
DECLARE CURSOR statement |
A named result table is defined. The table is generated with an OPEN CURSOR statement. |
SELECT statement (select statement) |
An unnamed result table is defined and generated. |
Recursive DECLARE CURSOR statement |
This statement can be used to generate bills of material. |
The SELECT statement (select_statement)is subject to the rules that were specified for the DECLARE CURSOR statement (declare_cursor_statement)and those that were specified for the OPEN CURSOR statement.
The order of rows in the result table depends on the internal search strategies of the system and is arbitrary. The only reliable means of sorting the result rows is to specify an ORDER clause.
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.
· The result table is a named result table, that is, it must not have been generated by a select statement.