FOR構文 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLストアド プロシージャおよび埋め込みSQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
2021年7月
Language
日本語
Last Update
2021-09-23
dita:mapPath
ja-JP/vqj1592443206677.ditamap
dita:ditavalPath
ja-JP/wrg1590696035526.ditaval
dita:id
B035-1148
Product Category
Software
Teradata Vantage
[ label_name : ] FOR for_loop_variable
  AS [ cursor_name CURSOR FOR ] cursor_specification
  DO statement [...]
  END FOR [ label_name ] ;
cursor_specification
SELECT cursor_spec [,...]
  FROM {
    table_name [,...] |

    table_name {
      INNER |
      { LEFT | RIGHT | FULL } OUTER
    } JOIN table_name ON condition
  }
statement
{ SQL_statement |
  compound_statement |
  assignment_statement |
  condition_statement |
  [ label_name : ] iteration_statement [ label_name ] |
  ITERATE label_name |
  LEAVE label_name
}
compound_statement
[ label_name : ] BEGIN
  [ local_declaration ] [...]
  [ cursor_declaration ] [...]
  [ condition_handler ] [...]
  [ statement; ] [...]
END [ label_name ] ;
assignment_statement
SET assignment_target = assignment_source
condition_statement
{ CASE_statement | IF_statement }
iteration_statement
{ WHILE conditional_expression
    DO statement; [...] |

  LOOP
    statement; [...]
  END LOOP |

  FOR for_loop_variable AS [ cursor_name CURSOR FOR ] cursor_specification
    DO statement; [...]
  END FOR |

  REPEAT
    statement; [...]
    UNTIL conditional_expression
  END REPEAT
}
cursor_spec
{ column_name [ [AS] alias_name ] |

  expression [AS] alias_name |

  *
}
local_declaration
DECLARE {
  variable_name [,...] data_type [ DEFAULT { literal | NULL } ] |
  condition_name CONDITION [ FOR SQLSTATE [VALUE] sqlstate_cod ]
} ;
cursor_declaration
DECLARE cursor_name [ [NO] SCROLL ] CURSOR
  [ WITHOUT RETURN |
    WITH RETURN [ONLY] [ TO { CALLER | CLIENT } ]
  ]
  [ FOR { cursor_specification [ FOR { READ ONLY | UPDATE } ] |
          statement_name
        } 
  ] ;
condition_handler
DECLARE { CONTINUE | EXIT } HANDLER FOR
  { 
    { SQLSTATE [ VALUE ] sqlstate_code | condition_name } [,...] |

    { SQLEXCEPTION | SQLWARNING | NOT FOUND } [,...]

  } handler_action_statement ;