1. 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.
2. Enter complete path where your data files are located under Schema and Work Schema fields
and press Save button.
3. In topology manager, go to Logical Architecture >> File. Right click on File technology and
select New Logical Schema.
4. 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.
5. Right click on your newly create data model and select New Datastore.
6. Enter details required for creating Datastore and press Save button. See below screens for more
details.
7. 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.
8. SQL> conn ODI_MULTI_TEST
Enter 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.
9.
10. 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.
14. Reverse engineering model produces below output.
Do some modifications on source (file) data store.
Replace the resource name with #Project_Name.FILE_NAME.txt
19. Drag and drop count variable
Drag and drop Files_Count variable.
20. Drag and drop count variable.
Now, customized your package. It should look like below screen.
21. 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.
22. You can see the result of your package execution either in Operator or by viewing data of your
target table directly from Designer.
23. That's it, you have now successfully loaded data from multiple files to a single target table using
single interface.