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.

 

 

Creating SQL Variables

 

To create a new SQL variable:

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:

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.

 

 

Editing SQL Variables

 

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.

 

Dropping SQL Variables

 

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.