May 19, 2012, Saturday, 139


CREATE VARIABLE

From SQL PL Guide for DB2

Jump to: navigation, search

CREATE VARIABLE statement

Global variables are supported by DB2 since Version 9.5. They're improving data sharing between different SQL statements which are running in the same session (or connection). Global variables are a new object in DB2 an will stored in the catalog view SYSCAT.VARIABLES. They have to create with the CREATE VARIABLE statement. There're multiple possibilities to set and change the values of the variables.


Syntax:

 CREATE VARIABLE <varschema>.<varname> <datatype> [DEFAULT <value>]


Example:

 create variable GLOBAL.MYVAR INTEGER default 1



Link to the DB2 Information Center: DB2 9.5 DB2 9.7