Online Documentation for SQL Manager for DB2
SQL Variables
The SQL Variable is a global variable used to store the results of intermediate calculations or queries. Global variables have a session scope. This means that, although they are available to all sessions that are active on the database, their value is private for each session.
To create a new SQL variable:
- select the Database | New Object... main menu item;
- select SQL Variable in the Create New Object dialog;
- edit SQL variable properties using the appropriate tabs of SQL Variable Editor.
Hint: To create a new SQL variable, you can also right-click the SQL Variables node of the DB Explorer tree and select the New SQL Variable... context menu item.
To create a new SQL variable with the same properties as one of existing SQL variables has:
- select the Database | Duplicate Object... main menu item;
- follow the instructions of Duplicate Object Wizard.
Alternatively, you can right-click a SQL variable in the DB Explorer tree and select the Duplicate SQL Variable<SQL_variable_name>... context menu item.
Duplicate Object Wizard allows you to select the database to create a new SQL variable in, and to edit the result SQL statement for creating the SQL variable.
To edit an existing SQL variable:
- select the SQL variable for editing in the DB Explorer tree (type the first letters of the SQL variable name for quick search);
- right-click the object and select the Edit SQL Variable <SQL_variable_name>... context menu item, or simply double-click the SQL variable;
- edit SQL variable definition using the appropriate tabs of SQL Variable Editor.
To drop a SQL variable:
- select the SQL variable to drop in the DB Explorer tree;
- right-click the object and select the Drop SQL Variable <SQL_variable_name>... context menu item;
- confirm dropping in the dialog window.
Note: If more convenient, you can also use the following shortcuts:
Ctrl+N to create a new SQL variable;
Ctrl+O to edit the selected SQL variable;
Shift+Del to drop the object from the database.