Вы находитесь на странице: 1из 18

ODI11g: Creating an ODI Project and

Interface: Exporting an RDBMS Table to a


Flat File
Purpose
This tutorial walks you through the steps that are needed to create a project and an interface in
Oracle Data Intergrator (ODI) to export a relational table to a flat file.

Time to Complete
Approximately 40 minutes

Overview
A common task that is performed using ODI is to export data from a relational table and load this
data into a flat file. This tutorial walks you through the steps that are needed to create a project
and an interface that will export a relational table to a flat file. You also execute the interface and
verify the execution with ODI Operator.

Scenario
Linda works as a database administrator for Global Enterprise. In Global Enterprise, Linda is
responsible for performing database management and integration tasks on various resources
within the organization. In particular, Linda is responsible for data loading, transformation, and
validation. To begin working on her projects, Linda created the new Master repository and Work
repository. Now Linda needs to create a project and an interface to export data from a relational
table and load this data into a flat file.

Creating a New Project with Oracle Data Integrator


To create a new project within Oracle Data Integrator, perform the following steps:
1. Start ODI Designer: Start > Programs > Oracle > Oracle Data Integrator > ODI Studio .
Select WORKREP1 from the Login Name drop-down list if not already selected. Enter

SUPERVISOR in the User field and SUPERVISOR in the Password field. Click OK to login.

2. In the designer tab, click the Projects tab, click New Project icon
Project.

, and then click New

3. On the screen that appears, set the Name of the project to ODIexp_RT_FT in the Name field.
The Code field is filled automatically. Click Save icon
. The newly created ODIexp_RT_FT
project now appears in the Projects tree view. You have now successfully added a new ODI
project.

4 . You export a flat file directly to a relational table target. The knowledge modules required for
this are LKM File to SQL and IKM SQL Incremental Update. To import the KMs, expand the
Project tab in the left panel, right-click the Knowledge Modules folder and select Import
Knowledge Modules.

Note: In this example, the generic SQL KM is used. However, specific KMs for the RDBMS
technology can be used as well.

5 . On the screen that follows, in the File Name, navigate to xml-reference directory as shown in
the following screenshot. Click Open. The files to import should appear in the Import
Knowledge Modules window. Select IKM SQL to File Append. Click OK.

6. On Import Report window, click Close.

3 . Create your source table and populate it with data by executing the SQL commands provided
below. Expand connection ODI_STAGE > Tables > SRC_SALES_PERSON and verify that the
table is created successfully.

CREATE table "SRC_SALES_PERSON" (


"SALES_PERSON_ID" NUMBER(8,0) NOT NULL,
"FIRST_NAME" VARCHAR2(80),
"LAST_NAME" VARCHAR2(80),
"DATE_HIRED" VARCHAR2(80),
"DATE_UPDATED" DATE NOT NULL,
constraint "TRG_SALES_PERSON_PK" primary key("SALES_PERSON_ID")
)
/
begin
insert into ODI_STAGE.SRC_SALES_PERSON values
(11,'Andrew','Andersen','22/02/1999',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(12,'John','Galagers','20/04/2000',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(13,'Jeffrey','Jeferson','32422',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(20,'Jennie','Daumesnil','28/02/1988',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(21,'Steve','Barrot','24/09/1992',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(22,'Mary','Carlin','14/03/1995',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(30,'Paul','Moore','36467',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(31,'Paul','Edwood','18/03/2003',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(32,'Megan','Keegan','29/05/2001',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(40,'Rodolph','Bauman','29/05/2000',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(41,'Stanley','Fischer','37233',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(42,'Brian','Schmidt','25/08/1992',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(50,'Anish','Ishimoto','30/01/1992',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(51,'Cynthia','Nagata','28/02/1994',sysdate);
insert into ODI_STAGE.SRC_SALES_PERSON values
(52,'William','Kudo','28/03/1993',sysdate);
end

Creating a New ODI Source Model


Create a new ODI target model that will be used within your ODI Interface. To create a new ODI
target model, perform the following steps:
1 . Open ODI Designer. Click Models tab and select New Model. On the screen that appears, enter
the values provided in the following table. Click the Reverse Engineer tab.

Parameter

Value

Name

Oracle_RDBMS2

Technology

Oracle

Logical Schema

ODI_STAGE

2 . On the Reverse Engineer tab, set the Context to Global. Click Save button and then close
Oracle_RDBMS2 tab.

3 . In the Models tab, right-click the Oracle_RDBMS2 model. Select Reverse Engineer. To verify
that the SRC_SALES_PERSON datastore is successfully reversed expand the model as shown
below.

Creating a New ODI Interface to Perform RDBMS table to


Flat File Transformation
To create a new ODI Interface to perform RDBMS table to flat file transformation, pefrom the
following steps:
1 . In ODI Designer, click the Projects tab. Expand your project Export-RT-FT, and then expand
First Folder. Right-click Interfaces and select New Interface. In Optimization Context field,
select Global.

2 . On the screen that follows, enter the interface name as INT-EXP-RT_FT . For Staging Area
select Oracle: ODI_STAGE. Click Mapping tab.

3 . Click the Models tab to drag the source and target to the diagram. Drag the
TRG_SALES_PERSON.txt datastore from the Flat_File1 model into the Target container. Drag
the SRC_SALES_PERSON datastore from the Oracle_RDBMS2 model into the Source
Datastore container. When Designer asks Do you want to perform an Automatic Mapping?
click Yes.

Select the FIRST NAME column in Target Datastore and edit the mapping to read:
ltrim(SRC.FIRST_NAME) . This function removes left spaces in the FIRST_NAME column. In
the Execute on section, select Staging Area. Click OK. Repeat this step for columns LAST
NAME and DATE HIRED. Refer to the mapping implementation provided in the table below:
Column

Mapping implementation

SALES_PERSON_ID LTRIM(SRC_SALES_PERSON.SALES_PERSON_ID)
FIRST_NAME

LTRIM(SRC_SALES_PERSON.FIRST_NAME)

LAST_NAME

LTRIM(SRC_SALES_PERSON.LAST_NAME)

DATE_UPDATED

LTRIM(SRC_SALES_PERSON. DATE_UPDATED)

DATE HIRED

LTRIM(SRC_SALES_PERSON. DATE_HIRED)

4 . Click the Flow tab. Click Target (FILE_GENERIC). The properties for the target appear
below. For the IKM, select IKM SQL to File Append from the IKM drop-down list. Set the
IKM options: TRUNCATE to true, GENERATE_HEADER to false as shown below. Click
Save icon.

5 . To test your interface, click Execute button


. The following screen appears. Retain the
defaults and click OK. On the next screen, click OK.

6 . Open ODI Operator and verify that your interface was executed successfully. In Operator, click
Session List tab, select All Executions, and the then click refresh button
results for interface INT-EXP-RT-FT.

. View execution

7 . Double-click Step 2 and click the Execution tab. View the number of rows inserted into the
target datastore (15). Close the tab.

Вам также может понравиться