Presentation is loading. Please wait.

Presentation is loading. Please wait.

Oracle Data Integrator User Functions, Variables and Advanced Mappings

Similar presentations


Presentation on theme: "Oracle Data Integrator User Functions, Variables and Advanced Mappings"— Presentation transcript:

1 Oracle Data Integrator User Functions, Variables and Advanced Mappings
7 Oracle Data Integrator User Functions, Variables and Advanced Mappings 14-1

2 Objectives After completing this lesson, you will know how to use:
Variables Sequences User Functions Advanced Mappings 14-2

3 What Is a Variable? Variable – An ODI object which stores a typed value, such as a number, string or date. Variables are used to customize transformations as well as to implement control structures, such as if-then statements and loops, into packages. 14-3

4 Variable Scope Scope defines where the variable can be used.
Global variables are accessible everywhere (defined in the Others tab of the Designer tree). Project variables are accessible within the project (and defined under the project in the Designer tree). The scope is defined by the location of the variable: Global variables: in the Others view, under Global variables Project variables: in the Projects view, under Variables To refer to a variable, prefix its name according to its scope: Global variables: GLOBAL.<variable_name> Project variables: <project_code>.<variable_name> 14-4

5 Variable Configuration: The Definition
Historize: keep all values taken by the Variable Last value: only keep the most recent value Not persistent: discard the value Data type: Alphanumeric (250 chars) Date (Java format) Numeric (10 digits). Value given if no stored value Description of variable 14-5

6 Variable Configuration: The Query
Logical Schema used for refreshing SQL Refresh instruction The result of a SQL query can be stored into a variable: The query must return a single value of the correct type. The query is executed by a Refresh Variable package step. Can also refresh manually. 14-6

7 Using a Variable in The Mappings
When used, a variable is prefixed according to its scope: Global variable: GLOBAL.<variable_name> Project variable: <project_code>.<variable_name> Tip: Use the Expression Editor to avoid mistakes in variables names. Variables are used either by string substitution or by parameter binding. Substitution: #<project_code>.<variable_name> Binding: :<project_code>.<variable_name> 14-7

8 How to Create a Variable Step in a Package
Select the variable from the Projects or Others view. Drag and drop it into the package. Select the type of operation to perform: evaluate, set/increment, refresh or declare. Set the options for the operation to perform. 14-8

9 Variable Steps Declare Variable step type: Set Variable step type:
Forces a variable to be taken into account. Use this step for variables used in transformations, or in the topology. Set Variable step type: Assigns a value to a variable or increments the numeric variable of the value. 14-9

10 Variable Steps (cont.) Refresh Variable step type:
Refreshes the value of the variable by executing the defined SQL query. Evaluate Variable step type: Compares the variable value with a given value, according to an operator. You can use a variable in the value in the value 14-10

11 User Functions 14-11

12 What Is a User Function? User Function – A cross-technology macro defined in a lightweight syntax used to create an alias for a recurrent piece of code or encapsulate a customized transformation. 14-12

13 Simple Example #1 A simple formula:
If <param1> is null then <param2> else <param1> end if Can be implemented differently in different technologies: Oracle nvl(<param1>, <param2>) Other technologies: case when <param1> is null then <param2> else <param1> end And could be aliased to: NumberToTitle(<param1>, <param2>) 14-13

14 Simple Example #2 A commonly used formula: Could be aliased to: 14-14
If <param1> = ‘1’ then ‘Mr’ else if <param1> = ‘2’ then ‘Ms’ else if <param1> = ‘3’ then ‘Mrs’ else if <param2> = 77 then ‘Dr’ else if <Param2> = 78 then ‘Prof’ else ‘’ end if Could be aliased to: NumberToTitle(<param1>, <param2>) 14-14

15 Properties of User Functions
A user function always has: A syntax: defines how the function is called by other objects in ODI Several implementations specific to different technologies A scope Global functions can be used anywhere. Project functions can be used within their project. User functions are organized into groups. 14-15

16 How to Create a User Function
Select the Functions node in a project, or in the Others view Right-click > Insert Function Fill in the: Name Syntax Description Select the Group, or type in the name of a new group. 14-16

17 Defining the Implementations
Select the Implementations tab Click the Add button. Enter the code for the implementation Select the applicable technologies. 14-17

18 Syntax of the Implementations
The function's syntax and implementation arguments are specified in one of the following formats: $(<arg_name>) $(<arg_name>)<arg_type> If <arg_type> is supplied it must be s (string), n (numeric) or d (date). For example: $(title)s Argument names in the syntax and implementation should match exactly. Examples: Syntax: NullValue($(myvariable), $(mydefault)) Implementation: case when $(myvariable) is null then $(mydefault) else $(myvariable) end 14-18

19 Using User Functions At design-time, you can refer to user functions like any regular database function You can use them in mappings, joins, filters, procedures, etc. They are available in the expression editor. When the code is generated: Project functions are identified first, then global functions. If a function is recognized, it is turned into the implementation corresponding to the technology of the generated code. If the function is not recognized, the generated code remains unchanged. 14-19


Download ppt "Oracle Data Integrator User Functions, Variables and Advanced Mappings"

Similar presentations


Ads by Google