Use this statement to declare a SQL variable within a compound statement (BEGIN ... END).
DECLARE variable-name data-type
Variables used in the body of a procedure, trigger, or batch can be declared using the DECLARE statement. The variable persists for the duration of the compound statement in which it is declared.
The body of a Watcom-SQL procedure or trigger is a compound statement, and variables must be declared with other declarations, such as a cursor declaration (DECLARE CURSOR), immediately following the BEGIN keyword. In a Transact-SQL procedure or trigger, there is no such restriction.
SQL/2003 Persistent Stored Module feature.
The following batch illustrates the use of the DECLARE statement and prints a message on the database server messages window:
BEGIN DECLARE varname CHAR(61); SET varname = 'Test name'; MESSAGE varname; END
|Discuss this page in DocCommentXchange.
Send feedback about this page using email.
|Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|