Skip to main content

Load CSV file data in Oracle table using ODI

Let us see how to transfer CSV file data in an Oracle database table. A CSV (Comma-separated value) file basically stores tabular data (numbers and text) in plain-text form. It is a common and simple file format used by many applications.
Pre-requisites: Oracle database 10g Express Edition with *SQLPlus, Oracle Data Integrator (build version 11.1.1.0.7)
First, you need to create your .csv file. Open notepad and write the following!
EMPLOYEE_ID,FIRSTNAME,LASTNAME
1,Dean,Winchester
2,John,Winchester
3,Sam,Winchester
Save the file with filename as employee.csv
Next we need to create a corresponding table in Oracle to store this information. Open *SQLPlus and login with your credentials. Create table using following command!
create table csv_test(empid int primary key, firstname varchar(30), lastname varchar(30));
The data in this table will come from the .csv file that we will load using Oracle Data Integrator.
Now, open ODI Studio and follow the below steps!
Step 1: Create new data server, physical schema for CSV file
Under Topology navigator, go to Physical Architecture, expandTechnologies, right click the File technology and select new Data Server.
Create new data server and physical schema
Create new data server and physical schema
data_server_2
physical_schema
While creating your Physical Schema, you need to specify the location where your .csv file exists. In my case the file is located at C:\programs\java_documents\uploads
Step 2: Create logical schema for CSV file
create logical schema
create logical schema
Step 3: Create data model for CSV file
Under Designer tab, go to Models and create a new Model folder. Then create two models, one for the CSV file and the other for the Oracle table.
Create new data model
model1_2
Right click the created csv data model and select New DataStore
data_store_1
data_store_2
Create datastore
Create datastore
Note: The comma in Field Separator is added because it is a CSV file, and the double quotation mark in Text Delimiter is required because the contents have comma (example: 1, Dean, Winchester).
In a similar manner, create model for the Oracle table by the usual reverse engineering method!
create model for table
create model for table
Step 4: Create new interface
Finally, create a new interface named csv_test. LKM used is File to Oracle (SQLLDR) and IKM Oracle Incremental Update.
interface_1
interface_2
interface_3
Create new interface
Create new interface
Run the interface. Check the status of the operation under the Operatortab. If everything works fine you should now see the data inserted successfully in your Oracle table.
Output
Output
output_2

Comments

  1. Simply wish to say your article is as astonishing. The clarity in your post is simply great, and I could assume you are an expert on this subject. Same as your blog i found another one Oracle ODI 12c .Actually I was looking for the same information on internet for Oracle ODI 11g and came across your blog. I am impressed by the information that you have on this blog. Thanks a million and please keep up the gratifying work.

    ReplyDelete

Post a Comment

Popular posts from this blog

ODI KM Adding Order by Option

You can add Order by statement to queries by editing KM.I have edited IKM SQL Control Append to provide Order by.  1) Add an option to KM named USE_ORDER_BY, its type is Checkbox and default value is False. This option determines you want an order by statement at your query. 2)Add second option to KM named ORDER_BY, type is Text. You will get order by values to your query by this option. 3) Editing Insert New Rows detail of KM. Adding below three line code after having clause. That's it! <% if (odiRef.getOption("USE_ORDER_ BY").equals("1")) { %> ORDER BY <%=odiRef.getOption("ORDER_BY" )%> <%} %>  If USE_ORDER_BY option is not used, empty value of ORDER_BY option get error. And executions of KM appears as such below; At this execution, I checked the KM to not get errors if ORDER_BY option value is null. There is no prove of ORDER BY I'm glad.  Second execution to get  Ord...

Synchronous and Asynchronous execution in ODI

In data warehouse designing, an important step is to deciding which step is before/after. Newly added packages and required DW data must be analyzed carefully. Synchronous addings can lengthen ETL duration. Interfaces, procedures without generated scenario cannot be executed in parallel. Only scenario executions can be parallel in ODI. Default scenario execution is synch in ODI. If you want to set a scenario to executed in parallel then you will write “-SYNC_MODE=2″ on command tab or select Synchronous / Asynchronous option Asynchronous in General tab. I have created a package as interfaces executes as; INT_JOBS parallel  INT_REGIONS synch  INT_REGIONS synch  INT_COUNTRIES synch  INT_LOCATIONS parallel  INT_EMPLOYEES parallel (Interfaces are independent.) Selecting beginning and ending times and durations from repository tables as ODI 11g operator is not calculating these values. It is obvious in ODI 10g operator. SELECT    sess_no...

Oracle Data Integrator tools: OdiFileDelete and OdiOutFile

Hello everyone! It’s time for another cool ODI tutorial. Last time, I spoke about the   OdiZip tool and how it can be used to create zip files from a directory. Through this post, I will talk about two more tools related to  Files  namely  OdiFileDelete and  OdiOutFile . 1. OdiFileDelete The  OdiFileDelete  is a tool used to delete files present in a directory or a complete directory on the machine running the agent. Usage OdiFileDelete -DIR=<dir> | -FILE=<file> [-RECURSE=<yes|no>] [-CASESENS=<yes|no>] [-NOFILE_ERROR=<yes|no>] [-FROMDATE=<fromdate>] [-TODATE=<todate>] If  -FROMDATE  is omitted, all files with a modification date earlier than the  -TODATE  date will be deleted. If  -TODATE  is omitted, all files with a modification date later than the  -FROMDATE  date will be deleted. If both parameters are omitted, all files matching the  -FILE...