Previous Topic: Example 2Next Topic: Description


Select-Statement

The select-statement is the form of a query that you can issue in interactive SQL (using CA Datacom Datadictionary or CA Dataquery online) or in static SQL (embedded in a DECLARE CURSOR statement in a preprocessed batch program), but not in dynamic SQL. The result table returned by a select-statement is the result of the full-select statement.

Following is the syntax diagram for the select-statement:

Note: For the syntax of the full-select statement, see Full-Select Statement.

FOR UPDATE OF is a CA Datacom/DB extension.

►►─ full-select statement ────────────────────────────────────────────────────►

 ►─┬──────────────────────────────────────────────────────┬───────────────────►◄
   ├─┬───────────────────┬─┬────────────────────────────┬─┤
   │ └─ ORDER BY clause ─┘ └─ optimize-read-fetch-list ─┘ │
   │                 ┌─ , ──────┐                         │
   └─ FOR UPDATE OF ─▼─ c-name ─┴─────────────────────────┘

►──┬─────────────────┬──────────────────────────────────────────────────────►◄
   └─ QUERYNO nnnnn ─┘

Note: FOR READ/FETCH ONLY is a CA Datacom/DB extension.

FETCH FIRST is a CA Datacom/DB extension.

   ┌─ (only one use of each clause is allowed) ───┐
►►─▼─┬──────────────────────────────────────────┬─┴────────────────────────►◄
     ├─ OPTIMIZE FOR n ROWS ────────────────────┤
     ├─ FOR ─┬─ READ ──┬ ─ ONLY ────────────────┤
     │       └─ FETCH ─┘                        │
     └─ FETCH FIRST ─┬─────┬─┬─ ROW ──┬ ─ ONLY ─┘
                     └─ n ─┘ └─ ROWS ─┘

Note: OPTIMIZE FOR n ROWS is a CA Datacom/DB extension.