Searched CASE Syntax - Teradata Vantage - Analytics Database

SQL Stored Procedures and Embedded SQL

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Publication Date
June 2022
Content Type
SQL Reference
Publication ID
B035-1148-172K
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
frc1628111662093.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
ft:sourceId
dita
dita:id
rjx1472253414573
lifecycle
latest
Product Category
Teradata Vantageā„¢
CASE
  when_clause [...]
  [ ELSE statement [...] ]
END CASE ;
when_clause
WHEN conditional_expression THEN statement [...]
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
}
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
        } 
  ] ;
IF_statement
See IF.
CASE_statement
Either form of the CASE statement.
condition_handler
DECLARE { CONTINUE | EXIT } HANDLER FOR
  { 
    { SQLSTATE [ VALUE ] sqlstate_code | condition_name } [,...] |

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

  } handler_action_statement ;
cursor_specification
SELECT cursor_spec [,...]
  FROM {
    table_name [,...] |

    table_name {
      INNER |
      { LEFT | RIGHT | FULL } OUTER
    } JOIN table_name ON condition
  }
cursor_spec
{ column_name [ [AS] alias_name ] |

  expression [AS] alias_name |

  *
}