Date post: | 02-Jun-2018 |
Category: |
Documents |
Upload: | nareshreddyguntaka |
View: | 225 times |
Download: | 0 times |
of 52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
1/52
Copyright 2010, Oracle. All rights reserved.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
2/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
3/52
Copyright 2010, Oracle. All rights reserved.
Agenda
Variables User Functions Procedures Packages
Lab Overview Q&A
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
4/52
Copyright 2010, Oracle. All rights reserved.
Variables
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
5/52
Copyright 2010, Oracle. All rights reserved.
What Is a Variable?
Variable An ODI object whichstores a typedvalue, such as a number, string or date.Variables are used to customize transformationsas well as to implement control structures, suchas if-then statements and loops, into packages.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
6/52
Copyright 2010, Oracle. All rights reserved.
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 thevariable:
Global variables: in the Others view, under Globalvariables
Project variables: in the P rojects view, underVariables
To refer to a variable, prefix its name according toits scope:
Global variables: GLOBAL. Project variables: .
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
7/52
Copyright 2010, Oracle. All rights reserved.
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
Description ofvariable
Data type: Alphanumeric (250 chars)Date (Java format)
Numeric (10 digits).
Value given if no stored value
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
8/52
Copyright 2010, Oracle. All rights reserved.
Variable Configuration: The Query
SQL Refreshinstruction
Logical Schema used forrefreshing
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 Ref resh Var i ab l e package step. Can also refresh manually .
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
9/52
Copyright 2010, Oracle. All rights reserved.
Using a Variable in The Mappings
When used, a variable is prefixed according to its scope: Global variable : GLOBAL. Project variable : .
Tip: Use the Expression Editor to avoid mistakes in variables
names.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
10/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
11/52
Copyright 2010, Oracle. All rights reserved.
User Functions
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
12/52
Copyright 2010, Oracle. All rights reserved.
What Is a User Function?
User Function Across-technology macro
defined in a lightweight syntax used to create analias for a recurrent piece of code orencapsulate a customized transformation.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
13/52
Copyright 2010, Oracle. All rights reserved.
Simple Example
A simple formula:I f is nul l then else end if
Can be implemented differently in differenttechnologies: Oracle
nvl(, )
Other technologies:case when is nul l
then else end
And could be aliased to:NumberToTi t le (, )
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
14/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
15/52
Copyright 2010, Oracle. All rights reserved.
Note Functions in Execution Log
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
16/52
Copyright 2010, Oracle. All rights reserved.
How to Create a User Function
1. Select the Functions node in aproject, or in the Others view2. Right-click > Inew User Function3. Fill in the:
Name
Syntax Description
4. Select the Group , or type in thename of a new group.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
17/52
Copyright 2010, Oracle. All rights reserved.
Defining the Implementations
1. Select theImplementations tab
2. Click the Add button.3. Enter the code for the
implementation4. Select the applicable
technologies.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
18/52
Copyright 2010, Oracle. All rights reserved.
Syntax of the Implementations
The function's syntax and implementation arguments arespecified in one of the following formats :
$( ) $( )
If is supplied it must be s (string), n (numeric) or d (date). For example: $( t i t le )s
Argument names in the syntax and implementation should matchexactly. Examples:
Syntax:NullValue( $(myvar iable) , $(mydefaul t ) )
Implementation:case when $(myvar iable) i s nul l
then $(mydefaul t )e lse $(myvar iable)
end
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
19/52
Copyright 2010, Oracle. All rights reserved.
Using User Functions
At design-time, you can refer to user functions like anyregular 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.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
20/52
Copyright 2010, Oracle. All rights reserved.
Procedures
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
21/52
Copyright 2010, Oracle. All rights reserved.
What is a procedure?
Procedure A sequence of commands executed by database engines, the operating
system, or using ODI Tools. A procedure canhave options that control its behavior.Procedures are reusable components that canbe inserted into packages.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
22/52
Copyright 2010, Oracle. All rights reserved.
Procedure Examples
Email Administrator procedure:1. Uses the OdiSendMail ODI tool to send an administrative
email to a user. The email address is an option.
Clean Environment procedure:1. Deletes the contents of the /temp directory using the
OdiFileDelete tool 2. Runs DELETE statements on these tables in order:
CUSTOMER, CITY , REGION , and COUNTRY
Create and populate RDBMS table:1. Run SQL statement to create an RDBMS table.2. Run SQL statements to populate table with records.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
23/52
Copyright 2010, Oracle. All rights reserved.
Procedure Examples (cont.)
Initialize Drive procedure:1. Connect to a network drive using either a UNIX or Windows command (depending on an
option).2. Create a /work directory on this drive.
Email Changes procedure:1. Wait for 10 rows to be inserted into the INCOMING table.2. Transfer all data from the INCOMING table to the OUTGOING table.3. Dump the contents of the OUTGOING table to a text file.4. Email this text file to a user.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
24/52
Copyright 2010, Oracle. All rights reserved.
How to Create a New Procedure
1. Right-click the Procedures node under aproject and select New Procedure.
2. Enter:- The name- The description
3. Optionally, define the default:
- Source technology- Target technology
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
25/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
26/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
27/52
Copyright 2010, Oracle. All rights reserved.
Which Parameters Should Be Set?
The following parameters should be set in the command: Technology: Overrides the default technology for the procedure Logical Schema: For DBMS technologies (Jython, OS, and ODI
tools do not require a schema) Context: If you want to ignore the execution context Ignore Errors: If the command must not stop the procedure. A
warning is issued only if the command fails.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
28/52
Copyright 2010, Oracle. All rights reserved.
Valid Types of Commands
Some examples of the types of commands that can be used in ODIprocedures:
SQL statement
OS commands
ODI Tools
Jython programs
Executed on any DBMS technologyDELETE, INSERT, SELECT, statements.
Executed on theOperating System technologyIn OS-specific syntax using shell commands or binary programs
Executed on theODI API technology Any ODI tool command call.
Executed on theJython technology.Jython code interpreted by the agent (Extensibility Framework).
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
29/52
Copyright 2010, Oracle. All rights reserved.
More Elements
In addition, we have access to the following ODI-specific elements that canbe used within the commands:
Variables
Sequences
User Functions
They may be specified either in substitution mode #, or in bind mode:
They may be specified either in substitution mode #, or in bind mode:
Used like DBMS functions. They are replaced at code generation time by theirimplementation.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
30/52
Copyright 2010, Oracle. All rights reserved.
Types of Options
Options are typed procedure parameters- Checkbox , value or text
Options are used to control procedures:- Commands may or may not be executed depending on the
values of checkbox options.- Value or text options can be used within the command toparameterize the code.
Options have a default value . The value can also bespecified when the procedure is used.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
31/52
Copyright 2010, Oracle. All rights reserved.
How to Create a New Option
1. Right-click the nameof the procedure.
2. Select New Option.3. Enter:
- The name- The description- The help text
4. Select:
- A type- A default value- A position to
display in
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
32/52
Copyright 2010, Oracle. All rights reserved.
How to Make a Command Optional
1. Open a command andclick the Options tab
2. Select the option box if itshould trigger thecommand execution
3. If the command shouldrun, independently of anyoptions, select the AlwaysExecute check box
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
33/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
34/52
Copyright 2010, Oracle. All rights reserved.
Packages
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
35/52
Copyright 2010, Oracle. All rights reserved.
What Is a Package?
Package : An organized sequence ofsteps thatmakes up a workflow.
Each step performs a small task, and they arecombined together to make the package.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
36/52
Copyright 2010, Oracle. All rights reserved.
How to Create a Package
1. Create and name a blank package.2. Create the steps that make up the package:
Drag interfaces from the Projects view onto theDiagram tab.
Insert ODI tools from the toolbox.3. Arrange the steps in order:
Define the first step. Define the success path. Set up error handling.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
37/52
Copyright 2010, Oracle. All rights reserved.
Package Diagram
Diagram
Oracle DataIntegratortool step
Interface step(selected)
Interface step(selected)
ToolboxToolbar
Procedurestep
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
38/52
Copyright 2010, Oracle. All rights reserved.
Package Diagram Toolbar
Execute package Execute selected step
Edit selected stepHide/showsuccess links
Hide/showfailure links
Select
Next step onsuccess
Next stepon failure
Duplicateselection
Delete selection
Rearrangeselection
Print package
Page setup
Shows errorsin the diagram
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
39/52
Copyright 2010, Oracle. All rights reserved.
Steps
The two most common package steps are:- Interface steps- ODI tool steps
Steps are created and sequenced in the package diagram.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
40/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
41/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
42/52
Copyright 2010, Oracle. All rights reserved.
Note Interfaces Are Reusable
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
43/52
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
44/52
Copyright 2010, Oracle. All rights reserved.
How to Create an ODI Tool Step
1. In Toolbox, expand thegroup containing the toolthat you want to add.
2. Click the tool.
3. Click the diagram.- A step named afterthe tool appears.
4. Change the step namein the Properties panel.
5. Set the tools properties.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
45/52
Copyright 2010, Oracle. All rights reserved.
Note Tool Steps Are Not Reusable
A Si l P k
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
46/52
Copyright 2010, Oracle. All rights reserved.
A Simple Package
This package executes two interfaces, and then archives somefiles.
If one of the three steps fails, an email is sent to theadministrator.
Step onfailure
First step
Step on success
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
47/52
Copyright 2010, Oracle. All rights reserved.
How to Sequence Package Steps
1. Define the first step.- Right-click and select First Step.
2. Define the success path.a. Select the Next step on success tool. b. Click the first step, the second step, and so on for the entire
success path.3. Set up error handling.
a. Select the Next step on failure tool. b. Click one step, then click the next step.c. Repeat to define the failure path wherever needed.
4. To delete links or steps:a. Use the Select tool to select a link or step.b. Click the Delete selection button (or press the Delete key on
the keyboard).
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
48/52
Copyright 2010, Oracle. All rights reserved.
Executing a Package
1. Click the Executebutton.
2. Open Operator Navigator.- The package is
executed as a session.
- Each package step isa step in OperatorNavigator.- Tool steps appear
with a single task.
- Interface steps showeach command
as a separate task.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
49/52
Copyright 2010, Oracle. All rights reserved.
Lab Overview
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
50/52
Copyright 2010, Oracle. All rights reserved.
Lab Objectives
In this lab, you will learn how to:
Create a user function Create a variable
Create a package Create a procedure
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
51/52
Copyright 2010, Oracle. All rights reserved.
8/10/2019 P.10 PTS ODI11g Variables Functions Procedures Packages
52/52