Table of Contents
DECLARE Statement Syntax
The DECLARE statement is used to define various items local to a routine:
Syntax
variable_declaration : DECLARE variable_name_list data_type [default_clause] cursor_def : DECLARE cursor_name CURSOR FOR direct_select_statement_multiple_rows
Description
DECLARE is allowed only inside a BEGIN … END compound statement.
Examples
CREATE PROCEDURE sp1( x VARCHAR(500) ) BEGIN -- declare cursor: DECLARE curs1 CURSOR FOR SELECT f1, f2, f5 FROM T1 join T2 WHERE f3 > 10; -- declare local variables of procedure: DECLARE xname VARCHAR(5) DEFAULT 'bob'; DECLARE newname VARCHAR(5); DECLARE xid INT; ... END;