Loading data in oracle using shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loading data in oracle using shell scripts
# 1  
Old 04-17-2012
Bug Loading data in oracle using shell scripts

Hi ,

I have a scenario, i have a directory where i receive around 14-15 files at a interval of 20-40 min not fixed, i want to write a unix scripts which invoke sqlldr command to load files into oracle automatically as soon as the file hit the directory.

Any help will be appreciated.

Thanks

Rajesh
# 2  
Old 04-17-2012
Code:
find $filepath -maxdepth 1 -type f  | while read file
do
sqlldr $user/$password@dbname control=$controlfile bad=$badfilepath/${file}_bad log=$logfilepath/${file}_log
wait
mv $filepath/$file $archive
done

If you have any specific naming format for data file this code can be trimmed. archive,logfilepath,badfilepath are directories, The reason I am using them is to avoid "find" feeding log/bad files to sqlldr.

Last edited by 47shailesh; 04-17-2012 at 12:17 PM.. Reason: correction
# 3  
Old 04-17-2012
Hi

My directory is fixed where the file will come, sqllder is written in a scripts which is in another directory. Now the requirment is that as soon as the file is reached to the directory there should be some means which sense that a file has come and it will trigger the shell scripts containg sqlldr scripts.

Thanks for understanding.

Rajesh
# 4  
Old 04-17-2012
in that case use a cron to run this script every X mins. Assuming name of this script is kept fileuploader.sh
Code:
if ! ps -ef | grep fileuploader.sh | grep -v grep; then
    find $filepath -maxdepth 1 -type f  | while read file
    do
        sh sqlldr_script.sh $file
        wait
    done
fi

# 5  
Old 04-17-2012
File transfers are not instantaneous and data loads are not instantaneous.
This sort of process needs very careful design to avoid loading the same file twice or loading a part-transferred file. Common designs involves transferring files under a temporary name, then renaming them after successful transfer. Similarly loading files, then renaming them after a successful data load. Another design involves using a "interlock" files to mark the common directory as "busy" until the transfers complete and "busy" during the data load.
Do you have such precautions in place?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to retrieve data from shell when connected to Oracle

I am trying to get the data from oracle table to a variable I have tried the below code #/usr/bin/sh echo " I am in correct loop" SPOOL_FILE=/app/scripts/alt.lst sqlplus /nolog <<END_SQL connect bindu/bindu@gis whenever sqlerror exit failure rollback;... (4 Replies)
Discussion started by: Kiransagar
4 Replies

2. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

3. Shell Programming and Scripting

Any shell scripts for cutting and pasting part of data?

Hi, I have a tab-delimited txt file as below. It is part of the original file. I want to cut the lines starting with "3" in column1 and paste them before the lines starting with "1" in column 1. So I will get Anyone knows any simple shell scripts to do that? The original file is... (5 Replies)
Discussion started by: cliffyiu
5 Replies

4. Shell Programming and Scripting

Calling oracle package Unix from shell scripts.

Hi, Can anyone tell me how to call a oracle package from a Unix shell script? I want to pass some input parameters to package and it will return me the output which I want to use further in my shell script. I want to know the way to capture the output values in my shell script. Please send some... (1 Reply)
Discussion started by: anil029
1 Replies

5. Shell Programming and Scripting

Loading Oracle data to unix in flat file

Hi I would like to know how to load oracle data to unix flat file using a shell script. Can we use sqlldr to import data from oracle, if so can anyone help me with it. (2 Replies)
Discussion started by: raghav288
2 Replies

6. Shell Programming and Scripting

Need shell script to extract data from oracle database

shell script (4 Replies)
Discussion started by: frns5
4 Replies

7. Shell Programming and Scripting

Function loading in a shell scripting like class loading in java

Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ... thanks in advance.. (1 Reply)
Discussion started by: mpsc_sela
1 Replies

8. Shell Programming and Scripting

Shell Script for Data loading in Oracle

Hi All I am new to unix. I need a shell script to load a datafile in to oracle. I already have a control file, and data file. all I need is if i execute the shell it must load the data using the ctl file to table. Control file : PAY0001.ctl Datafile : mon_grs_det.dat log file :... (3 Replies)
Discussion started by: raghuraja_r
3 Replies

9. UNIX for Advanced & Expert Users

Connecting to Oracle through unix shell scripts

Hi, Can some one help me in connecting to oracle through unix shell scripts with examples. Regards Narayana Gupta (1 Reply)
Discussion started by: guptan
1 Replies

10. Shell Programming and Scripting

ORACLE from Shell scripts

Hi, I have Oracle, and I want to execute simple queries in it. Is it possible to do this using a UNIX shell scripts. Are there any commands in Shell scripting where in I can communicate to ORACLE!? Thanks, (2 Replies)
Discussion started by: mohanprabu
2 Replies
Login or Register to Ask a Question