Generating a Scenario for a Procedure

Working with Procedures, Variables, Sequences, and User Functions 12-13 ■ MY_PROJECT_CODE.MY_VAR: Using this syntax allows you to use variables by explicitly stating the project that contains the variable. It prevents ambiguity when 2 variables with the same name exist for example at global and project level. The value of the variable will be substituted at runtime. ■ GLOBAL.MY_VAR: This syntax allows you to refer to a global variable. Its value will be substituted in your code. Refer to section Global Objects for details. ■ Using “:” instead of “”: You can use the variable as a SQL bind variable by prefixing it with a colon rather than a hash. However this syntax is subject to restrictions as it only applies to SQL DML statements, not for OS commands or ODI API calls and using the bind variable may result in performance loss. It is advised to use ODI variables prefixed with the character to ensure optimal performance at runtime. – When you reference an ODI Variable prefixed with the : character, the name of the Variable is NOT substituted when the RDBMS engine determines the execution plan. The variable is substituted when the RDBMS executes the request. This mechanism is called Binding. If using the binding mechanism, it is not necessary to enclose the variables which store strings into delimiters such as quotes because the RDBMS is expecting the same type of data as specified by the definition of the column for which the variable is used. For example, if you use the variable TOWN_NAME = :GLOBAL.VAR_TOWN_ NAME the VARCHAR type is expected. – When you reference an ODI variable prefixed with the character, ODI substitutes the name of the variable by the value before the code is executed by the technology. The variable reference needs to be enclosed in single quote characters, for example TOWN = GLOBAL.VAR_TOWN. The call of the variable works for OS commands, SQL, and ODI API calls.

12.2.3.1 Using Variables in Packages

Variables can be used in packages for different purposes: ■ Declaring a variable : When a variable is used in a package or in certain elements of the topology that are used in the package, it is strongly recommended that you insert a Declare Variable step in the packaget. This step explicitly declares the variable in the package. How to create a Declare Variable step is covered in Declaring a Variable . Other variables that you explicitly use in your packages for setting, refreshing or evaluating their values do not need to be declared. ■ Refreshing a variable from its SQL SELECT statement : A Refresh Variable step allows you to re-execute the command or query that computes the variable value. How to create a Refresh Variable step is covered in Refreshing a Variable . ■ Assigning the value of a variable : A Set Variable step of type Assign sets the current value of a variable. In Oracle Data Integrator you can assign a value to a variable in the following ways: – Retrieving the variable value from a SQL SELECT statement : When creating your variable, define a SQL statement to retrieve its value. For example, you can create a variable NB_OF_OPEN_ORDERS and set its SQL statement to: select COUNT from =odiRef.getObjectNameL,ORDERS,D where STATUS = ‘OPEN’.