Multiple files single target single interface

Post on 21-Jun-2015

2.783 views 2 download

Tags:

description

Steps to use a single interface to load multiple flat files of same structure into the single target table.

Transcript of Multiple files single target single interface

MULTIPLE FILES - SINGLE TARGET TABLE-SINGLE INTERFACE

Steps to use a single interface to load all the flat files of same structure into the single target table.

Let's consider that you have three Flat files namely FILE1.txt,FILE2.txt and FILE3.txt to be loaded into TRG_TBL table of ORACLE database.

In order to achieve this scenario, first of all you need to create a simple ODI routine to load data from FILE.txt file to TRG_TBL, by performing following steps.

Go to Start > Programs > Oracle > Oracle Data Integrator > ODI Studio .

Select DSBWR13 from the Login Name drop-down. Enter SUPERVISOR in the User field and password in the Password field. Click OK to login.

Go to Topology Manager >> Physical Architecture >> File >> FILE_GENERIC. Right click on FILE_GENERIC and select New Physical schema. See below screen shot for more info.

Enter complete path where your data files are located under Schema and Work Schema fields and press Save button.

In topology manager, go to Logical Architecture >> File. Right click on File technology and select New Logical Schema.

Choose Physical schema under Global context.

Create new project and import LKM File to SQL and IKM SQL Control Append knowledge modules.

Now, you need to reverse engineer source file.

Insert new model.

Right click on your newly create data model and select New Datastore.

Enter details required for creating Datastore and press Save button. See below screens for more details.

Now create RDBMS schema/user by executing below SQL query.

SQL> create user ODI_MULTI_TEST identified by password default tablespace users temporary tablespace temp;

Grant privileges to ODI_MULTI_TEST user using below command.

SQL> grant connect, resource to ODI_MULTI_TEST;

Connect to SQL using this newly create user and execute following commands.

SQL> conn ODI_MULTI_TESTEnter password:Connected.SQL> CREATE TABLE SRC_FILE_DETAILS 2 ( FILE_NAME VARCHAR2(10 BYTE) 3 );

Table created.

SQL> INSERT INTO src_file_details values ('FILE1');

1 row created.

SQL> INSERT INTO src_file_details values ('FILE2');

1 row created.

SQL> INSERT INTO src_file_details values ('FILE3');

1 row created.

Create target table.

SQL> CREATE TABLE TRG_TBL ( 2 "EMPNO" NUMBER(10,0) NOT NULL, 3 "ENAME" VARCHAR2(200), 4 "JOB" VARCHAR2(200), 5 "MGR" VARCHAR2(200), 6 "HIREDATE" VARCHAR2(200), 7 "SAL" VARCHAR2(200), 8 "COMM" VARCHAR2(200), 9 "DEPTNO" VARCHAR2(200), 10 CONSTRAINT "TRG_TBL_PK" PRIMARY KEY ("EMPNO") 11 );

Table created.

Now you need to create variables by performing below steps:

In Designer panel, go to Projects >> [PROJECTNAME] >> Variables.Right click Variables and select New Variable.

See below screens for variable creation steps.

In order to create target data server, perform the below steps:

In topology manager, go to Physical Architecture >> Oracle technology. Right click on Oracle technology and select Insert Data Server.

Enter required parameters and press Save button.

Insert Physical Schema

Insert Logical Schema

Create Target Model

Reverse engineer target model.

Reverse engineering model produces below output.

Do some modifications on source (file) data store.

Replace the resource name with #Project_Name.FILE_NAME.txt

Create Interface

Create Package

Click on Diagram tab.

Drag and drop count variable under diagram section of package.

Drag and drop File_Name variable.

Drag and drop MULTITEST interface.

Drag and drop count variable

Drag and drop Files_Count variable.

Drag and drop count variable.

Now, customized your package. It should look like below screen.

Before executing package, verify that your target table is empty, by performing following steps.

In Designer, go to Model >> TRG_TBL. Right click on TRG_TBL and select View Data.

It will show you TRG_TBL table content.

Your target table is empty. Now execute the package by performing below steps.

In Designer, go to Projects >> [YOURPROJECT] >> Packages >> [YOURPACKAGE].

Right click on [YOURPACKAGE] and select execute.

You can see the result of your package execution either in Operator or by viewing data of your target table directly from Designer.

That's it, you have now successfully loaded data from multiple files to a single target table using single interface.