Working with Variables

Creating Variables in the metadata

Creating the Metadata file

Variables can be created as metadata with the “Variable Set” metadata type.

To create a new Variable set :

  1. Click on the New Metadata button in the Project Explorer toolbar. The New Model wizard opens.
  2. Select the Variable Set type.
  3. Choose a name and a folder to store the metadata file. The metadata file will be created

Creating the Variables

To create a new Variable :

  1. Right-Click on the Set node and choose New Child and Variable.
  2. In the properties tab, give a name to the Variable

Variables properties

Name Mandatory Description
Name yes Name of the Variable
Type Type of the Variable : String, Integer, Boolean or Float. The default value will be String.
Refresh Query Used if a Refresh Connection is defined. This query will be executed to retrieve a value for the Variable. In case of a query returning multiple rows or multiple columns (or both), the first column of the first row will used as the value
Default Value The default value of the Variable
Saving Connection Connection used to save the values of the Variable. A connection should be defined first. See below for more information.
Refresh Connection Connection used by the Refresh Query. A connection should be defined first. See below for more information.
Default Operation Operation used when invoking the Variable Manager.

Associating connections to variables

Associating connections to Variables

Connections can be defined and shared in the Variable Set.
This will allow:

  1. to get values for the variable using a SQL order, through a refresh query defined on the variable
  2. to save and get the values of the Variables in a table

Defining a connection

To define a connection :

  1. Right-Click on the Set node and choose New > Connection.
  2. Give a name to the connection
  3. Drag and drop under the connection the metadata that you want to use for this connection.

Note: You can add several connections in the Variable Set.

Tip: You can use different types of metadata nodes in the connection : a server, a schema, a table or even a column. This can be useful to generate the proper SQL command for the refresh query.

Saving and Refreshing connections

Once the connections are defined in the variable set, they can be used to refresh or save the values of the variables.

The Refresh and the save connections can be defined for each variable in the properties tab in its own combo box.

The Refresh and the save connections can also be defined on the Set node. In this case, all the variables for which connections are not defined will use these connections.

Using the metadata to generate proper SQL Orders

The node that has been defined on the connection can be used to generate the SQL orders.
The node, in fact, is a link to the Metadata.

In the Refresh Query, you can use the Xpath or metadata functions provided by Semarchy Convergence for DI directly inside the { } enclosers.

If the metadata used in the connection is a schema, you can use the following syntaxes :

{ ./tech:physicalName() }
{ ./md:objectPath(.,'MYTABLE') }

If the metadata used in the connection is a table, you can use the following syntax :

{ ./tech:physicalPath() }

Using Variables in the Mappings

To use a Variable in a Mapping :

  1. Drag and drop the Variable node from the Metadata file into the Mapping. This will add the Variable as a new source in the Mapping.
  2. In the Mapping, drag and drop the Variable into the target column, the join or the filter expressions in which the Variable should be used.

In the Expression Editor the Variable will automatically have the following syntax :

%{VARIABLE_NAME}%

where VARIABLE_NAME is the name of the variable.

Using variables in processes

To use a variable in a mapping :

  1. Drag and drop the variable node from the metadata file into the process diagram. This will instanciate the Variable Manager object with a predefined metadata link to the variable. The predefined properties of the variable will automatically be set on the Variable Manager when the process will be generated (default value, connections, default Operation, ...)
  2. Modify the properties in the Properties Tab view

Tip: if you want get a value in a table to parameter a mapping, you can instantiate a variable in a process as explained below. Or if the variable has a refresh query, it will be used to get the value. You can then use the variable in the mapping as explained in the previous sections.

Syntax to use variables in expressions

In order to use a variable in an expression (action text or parameter), you will have to instanciate the variable in the process, and use the following syntax :

%{VARIABLE_NAME}%

where VARIABLE_NAME is the name of the variable.

Using variables in other variables

In order to use a variable in another variable, there are two cases :

The two variables are defined in the same metadata file

In this case, you will just have to use the following syntax :

%{VARIABLE_NAME}%

where VARIABLE_NAME is the name of the variable.

This syntax can be used in the query or in the default value.

The two variables are defined in different metadata files

In this case, before using the variable inside another variable, you will have to link the two metadata files together :

  1. Open the destination metadata file (the file in which is found the variable that will receive the other variable)
  2. Drag & drop the variable node you want to use from it’s metadata file to the opened metadata file (on the variable Set node)
  3. Use the following syntax :
%{VARIABLE_NAME}%

where VARIABLE_NAME is the name of the variable.

This syntax can be used in the query or in the default value.

Using variables in other metadata

In order to use a variable in other metadata properties (ie. a variable in a table condition), you will have to link the two metadata files together :

  1. Open the destination metadata file (the file in which is found the metadata that will receive the variable)
  2. Drag & drop the variable node you want to use from it’s metadata file to the opened metadata file
  3. Use the following syntax in the properties :
%{VARIABLE_NAME}%

where VARIABLE_NAME is the name of the variable.