28. Manage variables with SQL Workbench/J

28.1. Define a script variable - WbVarDef
28.2. Delete a script variable - WbVarDelete
28.3. Show defined script variables - WbVarList

All SQL Workbench/J specific command can only be used from within SQL Workbench/J

More details about using variables can be found in the chapter Variable substitution.

28.1. Define a script variable - WbVarDef

This defines an internal variable which is used for variable substitution during SQL execution.

There are two possibilities to define a variable.

The short syntax is: WbVarDef variable=value

The long syntax allows to define variables in a different way:

-variableThe name of the variable to be defined.
-valueThe value of the variable.
-file Read the variable definitions from the specified file.
-contentFile Read the contents of the variable from a the specified file.
-values Define a comma separated list of values that are used in the dialog that is shown when prompting for variable values.

More details and examples can be found in the chapter: Variable substitution

28.2. Delete a script variable - WbVarDelete

This removes a variable.

The syntax is WbVarDelete variable

variable is the name of the variable to be removed. The name can contain wildcards. WbVarDelete * will remove all defined variables. WbVarDelete id* will remove all variables starting with id.

28.3. Show defined script variables - WbVarList

This shows all defined variables when invoked without parameters. There are two ways to filter the result:

Supplying a simple wildcard value, e.g. WbVarList foo* to display variables where the name starts with foo

Using the parameter -match to define a regular expression only show variables where the name matches the regular expression, e.g. WbVarList -match="^(foo|bar).*" to list all variables where the name starts with foo or bar.