Select Encrypt. Encrypting a KM or 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’. 12-14 Oracle Fusion Middleware Developers Guide for Oracle Data Integrator Then in your package, you will simply drag and drop your variable and select the “Refresh Variable” option in the Properties panel. At runtime, the ODI agent will execute the SQL statement and assign the first returned value of the result set to the variable. – Explicitly setting the value in a package : You can also manually assign a value to your variable for the scope of your package. Simply drag and drop your variable into your package and select the “Set Variable” and “Assign” options in the Properties panel as well as the value you want to set. – Incrementing the value : Incrementing only applies to variables defined with a numeric data type. Drag and drop your numeric variable into the package and select the “Set Variable” and “Assign” options in the Properties panel as well as the desired increment. Note that the increment value can be positive or negative. – Assigning the value at runtime : When you start a scenario generated from a package containing variables, you can set the values of its variables. You can do that in the StartScenario command by specifying the VARIABLE=VALUE list. Refer to the OdiStartLoadPlan API command and the section Section 20.3.2, Executing a Scenario from a Command Line . How to create a Assign Variable step is covered in Setting a Variable . ■ Incrementing a numeric value : A Set Variable step of type Increment increases or decreases a numeric value by the specified amount. How to create a Set Variable step is covered in Setting a Variable . ■ Evaluating the value for conditional branching : An Evaluate Variable step acts like an IF-ELSE step. It tests the current value of a variable and branches in a package depending on the result of the comparison. For example, you can choose to execute interfaces A and B of your package only if variable EXEC_A_AND_B is set to “YES”, otherwise you would execute interfaces B and C. To do this, you would simply drag and drop the variable in your package diagram, and select the “Evaluate Variable” type in the properties panel. Evaluating variables in a package allows great flexibility in designing reusable, complex workflows. How to create an Evaluate Variable step is covered in Evaluating a Variable .

12.2.3.2 Using Variables in Interfaces

Variables can be used in interfaces in two different ways: 1. As a value for a textual option of a Knowledge Module. 2. In all Oracle Data Integrator expressions such as mappings, filters, joins, and constraints. To substitute the value of the variable into the text of an expression, precede its name by the character. The agent or the graphical interface will substitute the value of the variable in the command before executing it. The following example shows the use of a global variable named YEAR: Update CLIENT set LASTDATE = sysdate where DATE_YEAR = GLOBAL.YEAR DATE_YEAR is CHAR type Update CLIENT set LASTDATE = sysdate where DATE_YEAR = GLOBAL.YEAR DATE_YEAR is NUMERIC type The bind variable mechanism of the SQL language can also be used, however, this is less efficient, because the relational database engine does not know the value of the variable when it constructs the execution plan for the query. To use this mechanism,