In the Command on Target tab, specify the action code. The action code can itself

Working with Procedures, Variables, Sequences, and User Functions 12-11 A variable can be created as a global variable or in a project. This defines the variable scope. Global variables can be used in all projects, while project variables can only be used within the project in which they are defined. The variable scope is detailed in Section 12.2.3, Using Variables . The following section describes how to create and use variables.

12.2.2 Creating Variables

To create a variable:

1. In Designer Navigator select the Variables node in a project or the Global

Variables node in the Others view. 2. Right-click and select New Variable. The Variable Editor opens. 3. Specify the following variable parameters: 4. If you want the variables value to be set by a query:

1. Select the Refreshing tab.

2. Select the logical Schema where the command will be executed, then edit the

command text in the language of the schemas technology. You can use the Expression Editor for editing the command text. It is recommended to use Properties Description Name Name of the variable, in the form it will be used. This name should not contain characters that could be interpreted as word separators blanks, etc. by the technologies the variable will be used on. Variable names are not case-sensitive. That is, YEAR and year are considered to be the same variables. The variable name is limited to a length of 400 characters. Datatype Type of variable: ■ Alphanumeric 255 characters ■ Date This format is a Java date format that matches your machines local parameters. Note that you may need to adapt the format depending to the RDBMS ■ Numeric Maximum 10 digits ■ Text Unlimited length Action This parameter shows the length of time the value of a variable is kept for: ■ Non-persistent : The value of the variable is kept in memory for a whole session. ■ Last value : Oracle Data Integrator stores in its repository the latest value held by the variable. ■ Historize : Oracle Data Integrator keeps a history of all the values held by this variable. Use this option if you want to keep a history of the variable values or for debugging purposes. Note that Historize should be used selectively as the variable history is not automatically purged and grows each time the variable is used. Using history for many variables has an impact on the size of the work repository. Default Value The value assigned to the variable by default. Description Detailed description of the variable 12-12 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator Substitution methods such as getObjectName in the syntax of your query expression.

3. Click Testing query on the DBMS to check the syntax of your expression.

4. Click Refresh to test the variable by executing the query immediately. If the

variable action is set to Historize or Latest Value, you can view the returned value on the History tab of the Variable editor.

5. From the File menu, click Save.

The variable appears in the Projects or Others tree in Designer Navigator.

12.2.3 Using Variables

Using Variables is highly recommended to create reusable packages or packages with a complex conditional logic, interfaces and procedures. Variables can be used everywhere within ODI. Their value can be stored persistently in the ODI Repository if their action type is set to “Historize” or “Last Value”. Otherwise, with an action type of “Non-Persistent”, their value will only be kept in the memory of the agent during the execution of the current session. This section provides an overview of how to use variables in Oracle Data Integrator. Variables can be used in the following cases: ■ Using Variables in Packages ■ Using Variables in Interfaces ■ Using Variables in Object Properties ■ Using Variables in Procedures ■ Using Variables within Variables ■ Using Variables in the Resource Name of a Datastore ■ Passing a Variable to a Scenario ■ Generating a Scenario for a Variable Variable scope Use the Expression editor to refer to your variables in Packages, integration interfaces, and procedures. When you use the Expression editor the variables are retrieved directly from the repository. You should only manually prefix variable names with GLOBAL or the PROJECT_ CODE, when the Expression editor is not available. Referring to variable MY_VAR in your objects should be done as follows: ■ MY_VAR: With this syntax, the variable must be in the same project as the object referring to it. Its value will be substituted. To avoid ambiguity, consider using fully qualified syntax by prefixing the variable name with the project code. Note: It is advised to use the Expression editor when you refer to variables. By using the Expression editor, you can avoid the most common syntax errors. For example, when selecting a variable in the Expression editor, the variable name will be automatically prefixed with the correct code depending on the variable scope. Refer to Variable scope for more information on how to refer to your variables.