Create a Variable

A variable is an object that stores a single value, which can be a string, a number or a date. You can specify the value of the variables when you create the variable or set the value using a query expression.

The Variables page lists all the existing variables. Click the Actions icon (Actions icon) of a variable to edit, refresh, or delete it. All the available variables are also listed in the left panel of the Workflow Details page. You can use variables as steps in data flows and workflows.

To create a variable:

  1. On the Home page, click the required Project title. You are navigated to the Project Details page.
  2. In the left pane, click Variables. The Create Variable page appears.
  3. Enter a name for the variable.
  4. From the Data Type drop down, select one of the following:
    • Short text - The value can be alphanumeric, can contain special characters, and cannot exceed 255 characters.
    • Long text - The value can be alphanumeric, can contain special characters, and cannot exceed 64000 characters.
    • Numeric - The value can be a numeric value and can be preceded by a minus (-) sign. The value cannot exceed 10 digits. Possible value range is -999999999 to 9999999999.
    • Date - The value is a date format.
  5. In the Default Value field enter the value you want to assign to the variable. The allowed value depends on the Data Type you select.
  6. For variables that you modify, you can click the Actions menu next to the variable to open the Refresh Variable page to update the value. From the Keep History drop down select how you want the variable value to be displayed in the Refresh Variable page:
    • All Values - You can see the history of all the values held by this variable.
    • Latest Value - You can see only the latest value specified for the variable.
    • No History - Data Transforms does not keep the history of the values held by this variable.
    • Secure Value - This is useful when the variable contains passwords or other sensitive data. The value is not displayed in the Refresh Variable page.
  7. Enter a description for the variable.
  8. If you want the variable value to be set by a query, click the Refresh tab. Select the connection type and schema where you want to execute the command. Enter the query and click Validate to check the syntax of your expression.
  9. Click Save.

    The newly created variable is listed in the Variables page as well as in the Variables node in the left panel of the Workflow Details page.

Use Variables in a Data Flow

You can refer to variables in a data flow using the format #<variable_name>. During execution the variable is substituted by the value.

Here is an example of the use of a variable in a data flow:


Description of variables_in_data_flows.png follows

In this example, the data flow uses the variable DEVICE_TYPE as a step with the filter condition set as follows:

MOVIESALES_CA.DEVICE = '#DEVICE_TYPE'

The variable is quoted because the substituted value needs to be quoted. Since the variable value is substituted during execution, you can use it for many use cases such as in the transformation expression in the mapping.

Use Variables in a Workflow

The left panel of the Workflow Details page lists the variables that you can use as steps within a workflow.

You can drag and drop the variables you want to use in the workflow on the design canvas. The Properties Panel available on the right side of the design canvas displays various details about the step such as the following.
  • Name, Type, and the Step sequence number. These are non-editable values.
  • Click the link under Linked Object to view and update the details about the variable.
  • Operation: Select any one from the following:
    • Set Variable - There are two functions for this step:

      Update sets the current value of a variable.

      Increment increases or decreases a numeric value by the specified amount.

    • Refresh Variable - This variable step refreshes the variable by running the query specified in the variable definition.
    • Evaluate Variable: This variable step type compares the value of the variable with a given value according to an operator. If the condition is met, then the evaluation step is true, otherwise it is false.
  • Number of attempts on Failure
  • Time between attempts in seconds(s)
  • Log steps in journal - You can select from Always, Never, or Error.

Here is an example of the use of a variable in a workflow:


Description of variables_in_workflows.png follows

In this example, a variable called DEVICE _TYPE with the value "iphone" is used as a step in the workflow. The workflow performs the following actions:

  1. Execute the "REFRESH_DEVICE data flow.
  2. If the "REFRESH_DEVICE" data flow execution is successful, execute the "Load_movies_for_device" data flow.
  3. If the "Load_movies_for_device" data flow execution is successful, execute the "IF_IPHONE" variable evaluation step.
  4. If the variable value is equal to ‘iphone’, execute path for “true”.
  5. If the variable value is not equal to ‘iphone’, execute path for “false”.