Substitution variables can be used in SQL scripts in place of constants, names of columns or tables. If a SQL script contains any substitution variables, the dialog box prompting for values opens automatically when a user attempts to execute this script. To define a variable in the script, just type the variable in the actual SQL/SPL statement in the following format:
${varname} - where 'varname' is any user defined name.
Example 1:
SELECT * FROM tbl_factoryorders where orderamount > ${largeorder}
Example 2:
SELECT * FROM ${salestable} where useraccountno = '${accountnumber}'
The same script variable can be used in different SQL statements if it represents the same logical value. If you use a variable in more than one place in the script, you will be prompted for its value only once and the entered value is applied to substitute the variable in all places. The Preview panel, located below the variable grid, shows all SQL statements where the selected variable is used. After you enter a value for the variable, the preview panel shows the entered value instead of a variable name so that you could verify that the resulting SQL syntax is valid. SQL statements with substituted variables are sent to an Informix server exactly the same way as you see them in the Preview panel.