Showing posts with label Shell script. Show all posts
Showing posts with label Shell script. Show all posts

Friday, 17 May 2013

How to call SQL Loader from shell script --- for begginer

The shell script should be registered as a concurrent program, user can submit the program from request form.

Parameters from the program provided by the system.

$1 apps user name and password.
$2 user id (apps)
$3 user name
$4 Request id



Any other parameters which are aded in the concurrent program start from $5 and so on.


Basic parameters used while loading the data thorough SQL loader are datafile Name,control fil directory,Data file directory,temp control file directory,archive directory and error directory etc, below are the parameters created and are assigned to the variables.


DATA_DIR=$XX_TOP/$DATA_FILENAME_DIR
export DATA_DIR
echo 'Data Directory        ='$DATA_DIR

CTL_DIR=$XX_TOP/bin
export CTL_DIR
echo 'Control File Directory ='$CTL_DIR

ERR_DIR=$XX_TOP/error
export ERR_DIR
echo 'Error Directory       ='$ERR_DIR

ARCHIVE_DIR=$XX_TOP/archive
export ARCHIVE_DIR
echo 'Error Directory       ='$ARCHIVE_DIR

DATA_FILENAME=$DATA_DIR/$DATA_FILENAME_LIKE
export DATA_FILE_NAME
echo 'Datafile name         ='$DATA_FILENAME

CTL_FILENAME=$CTL_DIR/$CTL_FILE_NAME
export CTL_FILENAME
echo 'Control File name     ='$CTL_FILENAME

TEMP_CTL_FILENAME=/tmp/$4$CTL_FILE_NAME
export TEMP_CTL_FILENAME
echo 'Temp Control Filename ='$TEMP_CTL_FILENAME


For calling the sqlldr with the above parameters.

         . $APPL_TOP/APPSORA.env
         echo 'New ORACLE_HOME for 9i is '$ORACLE_HOME
         sqlldr userid=$1 control=$TEMP_CTL_FILENAME data=$Datafile_NAME log=$LOGFILE bad=$BADFILE discard=$DISFILE errors=999999

Monday, 13 May 2013

FTP Data file from one instance to current instance in Oracle apps

In the below sample script I am trying to transfer the data from source system to the current instance where I would be running the program.

The below script should be registered as a Concurrent program in Oracle apps.

I have 6 parameters ($5,$6,$7,$8,$9,$10) which I would be passing in the program.

The file will be transferred from the location specified in the first parameter i.e, $5 to the location specified in $6 i.e, second parameter in the concurrent program.

Below is the script.

XXSOURCE=$5
export XXSOURCE
echo $XXSOURCE
XXTARGET_DIR=$6
export XXTARGET_DIR
echo $XXTARGET_DIR
DATAFILE_NAME=${7}
export DATAFILE_NAME
echo 'Data Filename like       ='$DATAFILE_NAME
IP_Address=$8
export IP_Address
echo $IP_Address
User_Name=$9
export User_Name
echo $User_Name
PASSWORD=${10}
export PASSWORD
#echo $PASSWORD

ftp -in $IP_Address <<_FTP>>$FTPLOG
quote USER $User_Name
quote PASS $PASSWORD
bin
cd  $XXSOURCE
lcd $XXCUST_TOP/$XXTARGET_DIR
mget $DATAFILE_NAME*