0% found this document useful (0 votes)
8 views29 pages

Les - 08-MapAdv1 (Ban Quyen)

The document outlines advanced topics in designing mappings using ODI, focusing on business rules, variables, datasets, sequences, and temporary indexes. It covers the implementation of business rules, the use of variables and sequences, and best practices for performance optimization. Additionally, it includes practical exercises for applying these concepts in ODI mappings.

Uploaded by

Khanh Đỗ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views29 pages

Les - 08-MapAdv1 (Ban Quyen)

The document outlines advanced topics in designing mappings using ODI, focusing on business rules, variables, datasets, sequences, and temporary indexes. It covers the implementation of business rules, the use of variables and sequences, and best practices for performance optimization. Additionally, it includes practical exercises for applying these concepts in ODI mappings.

Uploaded by

Khanh Đỗ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Designing Mappings: Advanced Topics

Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Objectives

After completing this lesson, you should be able to:


• Use business rules, variables, and set-based operators
with ODI mappings
• Use datasets and sequences, including native sequences,
with ODI mappings
• Create temporary indexes to speed up retrieval

8-2 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Agenda

• Working with Business Rules


• Using Variables
• Datasets and Sets
• Using Sequences

8-3 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Business Rules in Mappings

• The following business rules are defined in mappings:


– Expressions
– Filters
– Joins
• ODI provides the following additional objects:
– Variables and sequences
– User-defined functions
– Substitution methods

8-4 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Business Rule Elements

The following types of clauses are available to implement


business rules:

Value String values should be enclosed with quotation marks:


‘USA’, ‘1 Jan 2000’. Numbers do not need quotation marks: 10

Source Attribute Drag an attribute or use the Expression Editor. It is prefixed with the
datastore alias.

DBMS Function Use the Expression Editor for the list of allowed functions and
operators.

DBMS Aggregate MAX(), MIN(), SUM(), AVG(), and so on.


ODI automatically generates the GROUP BY clause.

Combination Any combination of clauses is allowed:


SRC_SALES_PERSON.FIRST_NAME || ' ' ||
UPPER(SRC_SALES_PERSON.LAST_NAME)

8-5 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
More Elements

Other ODI-specific elements include:

Variables They may be specified either in substitution mode #<variable> or in


binding mode :<variable>.

Sequences They may be specified in either substitution mode #<sequence> or in


binding mode :<sequence>.

User functions They are used in the same way as DBMS functions, but replaced at
code generation by their implementation.

8-6 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Expression Editor
Toolbar Technology
Cut, Copy, Paste, Undo, Redo. Indicates the Determines tools available
language in use and the relevant technology and proper syntax

Code
Source Implementation of
Datastores the business rule
Attributes are
automatically
prefixed with
table aliases.
Variables
Project and global

Sequences
Project and global
(if present)

User functions
Project and global
(if present)

Language Elements Substitution


Database functions available methods
for the given technology odiRef API

Drag items into the Code box or double-click them.

8-7 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Agenda

• Working with Business Rules


• Using Variables
– Binding
– Substitution
• Datasets and Sets
• Using Sequences

8-9 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Using a Variable in Code

• 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 the
names of variables.
• Variables are used either by string substitution or by
parameter binding.
– Substitution: #<project_code or GLOBAL>.<variable_name>
– Binding: :<project_code or GLOBAL>.<variable_name>

8 - 10 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Binding Versus Substitution

• Substitution:
– Is correct in most cases
– The variable is replaced by its value before execution.
— Use single straight quotation marks for nonnumeric values.

SELECT * FROM MYTABLE WHERE NAME LIKE


'#GLOBAL.PATTERN’
• Binding:
– Works only for SQL clauses
– The statement is prepared in the DBMS without the value,
then the value is sent for processing.
– It may be used for DBMSs that optimize repeated statements
with different parameter values.

8 - 12 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Case Sensitivity

• Variable names are case-sensitive.


• For example: YEAR, Year, and year are three different
variables.

8 - 13 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Agenda

• Working with Business Rules


• Using Variables
• Datasets and Sets
– Datasets
– Sets
• Using Sequences

8 - 14 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Defining a Dataset

1
2

8 - 15 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Using Set-Based Operators

• Make sure that your technology supports


set-based operators.
– Check Support Set Operators.
– List of Operators:
INTERSECT, UNION, UNION ALL, MINUS
• In your mapping, add several datasets:
– Save before adding datasets.
– Share the same target structure.
– Order counts for precedence.
• Select an IKM that supports datasets.
– Datasets are merged from the Staging area.

8 - 16 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Example of SET: UNION

(Not shown, but required, is an output target)

8 - 17 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Agenda

• Working with Business Rules


• Using Variables
• Datasets and Sets
• Using Sequences
– Sequences
– Temporary Indexes
– Tracking Variables

8 - 18 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Types of Sequences

• Native sequences
• Standard sequences
• Specific sequences

8 - 19 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Support for Native Sequences

8 - 20 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Creating a Native Sequence

8 - 21 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Referring to Sequences

• Standard sequences:
– In code, the sequence name is followed by _NEXTVAL.
— This increments the sequence and then retrieves
the new value.
– You do not need to specify the scope.
– Substitution versus binding:
— Substitution: #<sequence_name>_NEXTVAL
— Binding: :<sequence_name>_NEXTVAL
• Native sequences:
– <sequence_name>.NEXTVAL

8 - 22 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Sequences: Best Practices

• ODI sequences are not as fast as DBMS sequences.


• DBMS sequences should be used wherever possible.

8 - 27 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Automatic Temporary Index Management

8 - 28 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Tracking Variables and Sequences

• You can track the actual values of variables and


sequences at run time.
• This feature allows you to see the actual values of
variables and sequences at execution time, making it
easier to troubleshoot ODI sessions.

Variable
Show/Hide
values button
Actual value of variable

8 - 29 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
How Variable and Sequence Tracking Works

• A new log level has been introduced in ODI 11g: Level 6,


which will have the same behavior as Level 5, but with the
addition of variable tracking.
• Set Log Level to 6 in order to track variable and sequence
values at run time.
• Note that tracking variable
and sequence values will
have a performance impact.

8 - 30 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Variable Actions

The Action field, when


displaying a variable,
is Keep History.

8 - 31 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Definition Tab of Session Step or Session Task

• Variable and Sequence values are displayed in the


Definition panel of Session Step or Task Step in Operator.
• Expand the Variable and Sequence Values node to display
them.
• Bind variables
(:MY_VAR) are
also tracked.

8 - 32 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Practice 08-1: Using Native Sequences with ODI
Mapping
1. In ODI, create the procedure
Create_ORCL_SEQ_FAM_ID and execute it to create the
sequence SEQ_FAMILY_ID in the RDBMS.
2. In ODI, create the native sequence SEQ_FAMILY_ID.
3. Create and execute the mapping Map_11-1 to load the
TRG_PROD_FAMILY target table by using the native
sequence to generate ID numbers for that table.
Source Map_11-1 Mapping Target
Model Model

Oracle
LKM SQL to Oracle Sales
MySQL_SRC
Application
Use sequence to
generate index on
FAMILY_ID attribute.
SRC_PRODUCT TRG_PROD_FAMILY

FAMILY_ID attribute
:SEQ_FAMILY_ID_NEXTVAL

8 - 36 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Practice 08-2: Using Temporary Indexes

1. Create an ODI mapping, Map_11-2, to load data into the


TRG_PRODUCT target table from two source tables.
2. Use source table TRG_PROD_FAMILY as a lookup table to
obtain the ID number (populated by a sequence in the
previous practice’s mapping).
3. For the lookup, create a temporary index to join the two
source tables on the FAMILY_NAME attribute.
Sources Map_11-2 Mapping Target
Model Model
LKM SQL to Oracle
Oracle
MySQL_SRC Model Sales
Application
Oracle
Sales
SRC_PRODUCT Application TRG_PRODUCT
TRG_PROD_FAMILY
Create a join on
FAMILY_NAME Create a unique index

8 - 37 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.
Practice 08-3: Using Sets with ODI Mapping

1. Create a duplicate of mapping MAP_9-2 as MAP_11-3.


2. Add a set component for the UNION.
3. For the source, specify the TRG_BULK_CUSTOMER
datastore from the Oracle Sales Application model.

Specify the UNION


operator to unite the
new source of data
with the default
dataset.

8 - 38 Copyright © 2021, Insight Data and/or its affiliates. All rights reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy