Previous Topic: CASE StatementNext Topic: DATACOM DUMP Syntax


Compound Statement Syntax

►►─┬────────────────┬─ BEGIN ATOMIC ──────────────────────────────────────────►
   └─ start-label: ─┘

   ┌─────────────────────────────────┐ ┌────────────────────────────┐
 ►─▼─┬─────────────────────────────┬─┴─▼─┬────────────────────────┬─┴─────────►
     ├─┤SQL-variable-declarations ├┤     └─ declare-cursor-stmt; ─┘
     └─┤condition-declarations ├───┘     

   ┌─────────────────────────┐
 ►─▼─┬─────────────────────┬─┴─┤proc-SQL-stmt-list ├ END ─┬─────────────┬─────►◄
     └─┤condition-handler ├┘                              └─ end-label ─┘

Expansion of SQL-variable-declarations

             ┌─ , ─────────────┐
├── DECLARE ─▼─ variable-name ─┴─ datatype ───────────────────────────────────►

 ►─┬─────────────────────────────┬─ ; ────────────────────────────────────┤
   └─ DEFAULT ─┬─ literal ─────┬─┘
               ├─ NULL ────────┤
               ├─ USER ────────┤
               └─ SYSTEM USER ─┘

Expansion of condition-declarations

├── DECLARE condition-name CONDITION ─────────────────────────────────────────►

 ►─┬─────────────────────────────────────────┬─ ; ───────────────────────────┤
   └─ FOR SQLSTATE VALUE character-constant ─┘

Expansion of condition-handler

                                          ┌─ , ──────────────────┐
├── DECLARE ─┬─ CONTINUE ─┬─ HANDLER FOR ─▼─┬─ condition-name ─┬─┴────────────►
             ├─ EXIT ─────┤                 ├─ sqlstate-value ─┤
             └─ UNDO ─────┘                 ├─ SQLEXCEPTION ───┤
                                            ├─ SQLWARNING ─────┤
                                            └─ NOT FOUND ──────┘

 ►─ proc-SQL-stmt; ──────────────────────────────────────────────────────────┤

Expansion of proc-SQL-stmt-list

   ┌──────────────────┐
├──▼─ proc-SQL-stmt; ─┴──────────────────────────────────────────────────────┤

Combinations and multiples of these two optional choices can be used.

The syntax contains a list of DECLARE CURSOR statements, each terminated by a semicolon. For DECLARE CURSOR information, see DECLARE CURSOR.

For proc-SQL-stmt syntax, see Proc-Body Syntax.

SYSTEM USER is a CA Datacom/DB extension.