29
ODI11g: Creating an ODI Project and Interface: Exporting a Flat File to a RDBMS Table Purpose This tutorial walks you through the steps that are needed to create a project and an interface in Oracle Data Integrator (ODI) to export a flat file to another flat file. Time to Complete Approximately 40 minutes Overview A common task that is performed using ODI is to export data from a flat file and load this data into RDBMS table. This tutorial walks you through the steps that are needed to create a project and an interface that will import a file to a staging area, perform some minor transformations, and then write the data to a table. You also execute the interface and verify the execution using 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 source flat file, perform transformations, and load this data into RDMBS table.

Exporting a Flat File to a RDBMS Table

  • Upload
    ravi405

  • View
    14

  • Download
    2

Embed Size (px)

DESCRIPTION

Example shows how to import data to a Table from a flat file.

Citation preview

ODI11g: Creating an ODI Project and Interface: Exporting a Flat File to a RDBMS Table

Purpose

This tutorial walks you through the steps that are needed to create a project and an interface in Oracle Data Integrator (ODI) to export a flat file to another flat file.

Time to Complete

Approximately 40 minutes

Overview

A common task that is performed using ODI is to export data from a flat file and load this data into RDBMS table. This tutorial walks you through the steps that are needed to create a project and an interface that will import a file to a staging area, perform some minor transformations, and then write the data to a table. You also execute the interface and verify the execution using 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 source flat file, perform transformations, and load this data into RDMBS table.

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 , and then click New Project.

3. On the screen that appears, set the Name of the project to ODI_exp_FT_RT in the Name field.

The Code field is filled automatically. Click Save icon . The newly created ODI_exp_FT_RT 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 KMs are 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. Press and hold the CTRL key to select IKM SQL to Incremental Update and LKM File to SQL. Click OK.

6. On Import Report window, click Close. Expand the Loading (LKM) and Integration (IKM) folders, and view each imported KM in the tree view as shown below.

Creating RDBMS Schema for ODI Target Datastore

You need to create a schema to host the ODI RDBMS target datastore.

To create a new RDBMS schema for the ODI datastore, perform the following steps:

1. Start SQL Developer. You will create the new schema/user by executing the following SQL commands:

create user ODI_STAGE identified by ODI_STAGE

default tablespace users temporary tablespace temp;

grant connect, resource, create trigger, create view to ODI_STAGE;

2. In SQL Developer create new connection called ODI_STAGE. Enter User name as ODI_STAGE with password ODI_STAGE. For SID enter ORCL. Click Test to verify connection, and then click Connect.

3 . Create your target table by executing the SQL commands provided below. Expand connection ODI_STAGE > Tables > TRG_SALES_PERSON and verify that the table is created successfully.

CREATE table "TRG_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")

)

Creating a New ODI Target Dataserver and the Physical Schema

Note: Skip this section, if you completed the OBE " Creating an ODI Project and Interface: Exporting RDBMS Table to a Flat File" earlier.

After you created the new database target datastore, you need to create a new ODI target data server and the Physical schema. To create the ODI target data server and physical schema, perform the following steps:

1. In ODI, Open ODI Topology Navigator and then select the Physical Architecture tab. Expand Technologies, right-click Oracle and select New Data Server.

2. In the Data Server: New window, enter the values provided in the table below. Click the JDBC tab.

ParameterValue

Name ODI_STAGEInstance/dblink (Data Server) ORCLUser ODI_STAGEPassword ODI_STAGE

3 .Click for JDBC Driver. Select Oracle JDBC Driver. Click OK. Click for JDBC Url, select jdbc:oracle:thin:@<host>:<port>:<sid>, and then click OK. Edit the Url to read: jdbc:oracle:thin:@localhost:1521:ORCL for Oracle Database. Note: Do not copy and paste in the JDBC Url field. This may cause problems with entering a valid URL string.

4 . Click Test Connection. In the window that opens, click Yes to save your data. In the Information window, click OK. Click Test to verify successful connection. Click OK.

5 . Click Expand Oracle technology node, right-click ODI_STAGE dataserver, and then select New Physical Schema.

6 . In Schema (Schema) and Schema (Work Schema) field enter your ODI_STAGE schema. Click Save button. Close ODI_STAGE.ODI_STAGE physical schema window. In the Information window, click OK.

7 . Open Logical Architecture tab, expand Technologies > Oracle. Right-click Oracle technology and then select New Logical Schema.

1 . Name logical schema ODI_STAGE. In the Global context, connect this logical schema to ODI_STAGE physical schema as shown below. Click Save button and then close the tabs.

Creating a New ODI Target 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.

ParameterValue

Name Oracle_RDBMS1Technology OracleLogical Schema ODI_STAGE

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

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

Creating a New ODI Interface to Perform Flat File to RDBMS Table Transformation

To create a new ODI Interface to perform flat file to RDBMS table transformation, pefrom the following steps:

1 . In ODI Designer, click the Projects tab. Expand your project Export-FF-RT, and then expand First Folder. Right-click Interfaces and select New Interface. In Optimization Context field, select Development.

2 . On the screen that follows, enter the interface name as INT-EXP-FF-RT . If selected, deselect the Staging Area Different From Target check box. Click the Mapping tab.

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

4 . Set the value for the DATE_UPDATED column in Target Datastore to System date. In Target Datastore, select DATE_UPDATED. In the Implementation tab, enter SYSDATE. Select Staging Area in the Execute on section. Make sure that Active Mapping checkbox is selected.

5 . 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:

ColumnMapping implementation

FIRST NAME Ltrim(SRC.FIRST_NAME)LAST NAME Ltrim(SRC.LAST_NAME)DATE HIRED Ltrim(SRC.DATE_HIRED)

6 . Click the Flow tab. Click the SrcSet_0 (FILE GENERIC) datastore . The properties for the source appear below. For LKM, select LKM File to SQL from the LKM drop-down list if not selected. Now you need to ensure that the temporary objects created during transformation are deleted. Set the LKM option DELETE_TEMPORARY_OBJECTS to <Default>: true as shown below.

7 . Click the Target datastore. Select IKM SQL Incremental Update. Set the IKM option

Flow_Control to False. Set the IKM option DELETE_ALL to True. Click Save .

8 . To test your interface, click Execute button . The following screen appears. Retain the defaults and click OK. On the next screen, click OK.

9 . Open ODIOperator and verify that your interface was executed successfully. In Operator, click

Session List tab, select All Executions, and the then click refresh button . View execution results for interface INT-EXP-FF-RT.

10 .

Double-click Step 12 and click the Execution tab. View the number of rows inserted into the target table (16).

11 .

Open the Interface tab. Select Mapping tab, right-click Target Datastore - TRG_SALES_PERSON, and then select Data.. View Data inserted in the target table. Cloae Data Editor. Close tabs.