Search This Blog

Sunday, December 20, 2009

SQL Loader (SQLLDR) in Oracle Applications

One of the executable type in Oracle applications is SQL*Loader. In this post we will discuss more about how to define, create and use this type of Execution Method.

Execution Method SQL*Loader is used to load data into database table using SQL*Loader. Below are the steps that needs to completed
1) Create Control File and copy it in the TOP/bin directory. E.g. if your custom application top directory is $XX_TOP, then the file should be copied in $XX_TOP/bin directory


OPTIONS (SKIP=1)
LOAD DATA infile '%1'
APPEND INTO TABLE sv_test_tbl
FIELDS TERMINATED BY "," optionally enclosed by '"'
(
item_number "trim(:item_number)"
, description "trim(:description)"
, attribute1 "trim(:attribute1)"
, process_flag Constant 'UNPROCESSED'
)


2) Create an executable with execution method as SQL*Loader and use the control file Name as Execution file Name. The Application should same as where the file is copied.

3) Create a concurrent program definition and use the executable created above.
It is optional to have any parameters to the program, but in this case the data file name should be same as control file name except the extension for the data file being .dat
If you notice in the control file definition above I have used %1 as the infile name. This is how parameters are referenced in control file.
So now we can create conc. program with a file name as a parameter(Full file name with path should be entered and this is case sensitive.)

4) Assign this program to the request group and it is ready to be used.

5 Comments:

Anonymous said...

you have a nice site. thanks for sharing this valuable resources. keep it up. anyway, various kinds of ebooks are available here

http://feboook.blogspot.com

Suresh Vaishya said...

Thanks for your feedback.. appreciate it.

Regards.
Suresh

nicetoknow said...

I am calling an INIFILE thru a shell script. Need to load multiple files in a table.
-- .sh file
sqlldr $UID control=$APP_BIN/adsm_loadtemptable.ctl, bad=$LOADERBAD, log=$LOADERLOG, errors=10000

-- ctl file
LOAD DATA
INFILE '/usr/local/pplbatch/daily_scripts/training/admd/data/data.csv'
REPLACE
....
I may get multiple files like data1.csv, data2.csv...
how do I handle this.. How can I load multiple files data into the table using ctl file..
I may not know the file names loading daily in the data directory....
Appreciate your help

Suresh Vaishya said...

Check out http://sureshvaishya.blogspot.com/2010/03/based-on-request-from-one-of-our-reader.html

Regards,
Suresh

Anonymous said...

Hi Suresh,

Is there anyway to load multiple data files to multiple tables in same load session? If there is such case, request you to please explain with an example? I want the input files to be picked up dynamically during the load session.

Copyright (c) All rights reserved. Presented by Suresh Vaishya