VAR
Defines variables. Variables can be used to dynamically control script execution. You can store different types of values in variables. The syntax is:
Syntax
VAR[Variable name][Variable value]
Parameters
Variable name
The name of the variable. Use descriptive names.
Variable value
The value of the variable. The values can be of any type.
To reference a variable use the following syntax:
%VAR%
How to use a variable
1 In Main file, choose New. In the list of transformation instructions, choose VAR. Variable appears.
2 In Name, type the variable name, as shown in Figure 5‑57. In Value, type the variable value. In this example, the variable contains the name of a table.
Figure 5‑57 Creating a variable
3 In Variable, choose OK. Variable appears in Main file.
4 In Main file, choose New. In the list of transformation instructions, choose EXPESSION. Expression appears.
5 In Table, select a database from the drop-down list, and type the following expression in the table box, as shown in Figure 5‑58:
[%TABLE%]
Figure 5‑58 Using a variable
6 In Column, type the name of the new column.
7 In Expression, type the expression for calculating the value of the new column. Use the variable reference where needed.
[SalesData].[%TABLE%].[QUANTITYINSTOCK]*[SalesData].[%TABLE%].[MSRP]
8 Choose OK, and select Save, to save the expression.
9 Choose Run. The log, as shown in Figure 5‑59, displays that the TABLE variable is replaced by its value, CarInventory.
Figure 5‑59 Running a project
How to manage the transformation process when exceptions occur
Users can decide not to stop the transformation process when errors occur via the TRANSFORM tab. By default, the loading process stops whenever an error is encountered. However, thanks to new ONERROR instructions for the transformation script, it is now possible to choose whether you want the transformation process to stop in the case of error or to continue running. This allows the transformation process to ignore any columns that present errors during the process, leaving them to be fixed and processed later if desired.
ON ERROR
In the TRANSFORM tab, you can create new instructions: ON ERROR continue and ON ERROR break. This is done by clicking on “New”, selecting “ON ERROR” from the list of available instructions that appears and then choosing either “continue” or “break” as needed.
Use the “up” and “down” arrows at the top of the tab to position your instructions wherever you want them to be in your rows of instructions. (See Figure 5‑60).
Figure 5‑60 Managing exceptions using the Transform tab