Oracle Database
--
Questions
--
Followers
Top Experts
SQLLoader / UNIX Script
Hi, I've been asked to create a UNIX script to run Oracle SQLLoader.
Has anyone got a good example of this?
I want to pass the file locations of the control file, log file AND data file to SQLLoader.
The UNIX script just needs to check that the relevant files exist, pass the information to SQLLoader
(via the command line) and then check that everything went OK (i.e check for a .bad file, etc.)
Any help would be appreciated.
Has anyone got a good example of this?
I want to pass the file locations of the control file, log file AND data file to SQLLoader.
The UNIX script just needs to check that the relevant files exist, pass the information to SQLLoader
(via the command line) and then check that everything went OK (i.e check for a .bad file, etc.)
Any help would be appreciated.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
HI mrt1
You can do following..
Create a shell script, in which store control,log and bad file locations in a host variables, say cfile,lfile and bfile respectively.By using UNIX shell syntax , check all files/path exist.If everything is fine then execute sqlloader as below...
sqlldr userid/passwd control=$cfile/ctl_file.ct l log=$lfile/logfile.log bad=$bfile/bad_file.bad
Include this in shell script.
good luck.
kp397
You can do following..
Create a shell script, in which store control,log and bad file locations in a host variables, say cfile,lfile and bfile respectively.By using UNIX shell syntax , check all files/path exist.If everything is fine then execute sqlloader as below...
sqlldr userid/passwd control=$cfile/ctl_file.ct
Include this in shell script.
good luck.
kp397
Below is a short and simple one. [Assume $1->controlfile,$2->logfil e, $3->badfile,
userid=scott/tiger, and the email address to be notified is abc@xyz]
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -----
#!/bin/sh
if [ $# -ne 3 ]; then
echo "Usage: $0 controlfile logfile badfile"
exit
fi
sqlldr scott/tiger control=$1 log=$2 bad=$3 #[,keyword=value,...]
if [ `cat $3 | wc -l` -gt 0 ]; then
mailx -s "SQL*LOADER badfile" abc@xyz < $3
fi
userid=scott/tiger, and the email address to be notified is abc@xyz]
--------------------------
#!/bin/sh
if [ $# -ne 3 ]; then
echo "Usage: $0 controlfile logfile badfile"
exit
fi
sqlldr scott/tiger control=$1 log=$2 bad=$3 #[,keyword=value,...]
if [ `cat $3 | wc -l` -gt 0 ]; then
mailx -s "SQL*LOADER badfile" abc@xyz < $3
fi
You can use the command-line options:
sqlldr scott/tiger control=emp.ctl data=emp.dat
The data option is overwriting our "INFILE" section in the control-file !
To check your result, use i.e. "grep","sed","awk" from the commandline to check your log-file.
sqlldr scott/tiger control=emp.ctl data=emp.dat
The data option is overwriting our "INFILE" section in the control-file !
To check your result, use i.e. "grep","sed","awk" from the commandline to check your log-file.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
You could also check for existence of bad file by
if [ `ls -ltr bad | wc -l` -ne 0 ]
echo " bad file exists " >> call_loader.log
fi
if [ `ls -ltr bad | wc -l` -ne 0 ]
echo " bad file exists " >> call_loader.log
fi
Yuck....it shud have been somethin like *.bad instead of bad.
Oracle Database
--
Questions
--
Followers
Top Experts
Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.