Advertisement

[x]
Attachment Details

Running sqlldr and sqlplus in korn shell script

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6
I am trying to run sqlplus and sqldr from a korn shell script.  See the script below. It run step 2 but doesnt go to step 3.  If i remove step 2 it runs step 3 but it give me >> unmatched error.   Also eveytime it does as step i guess it clears out the logfile. I want to concatenate the logfile. How do i do that ?
 

#!/usr/bin/ksh
#---------------------------------------------------------------------#
# Name:     recip_invoice_dim_sqlldr.ksh                              #
#                                                                     #
# Version:  1.0                                                       #
#                                                                     #
# Created:  06/14/07                                                  #
#                                                                     #
# Purpose:  Loads the ReCip data in FIN_INVOICE_DIM                   #
#                                                                     #
# Args:     n/a                                                       #
#                                                                     #
# Modifications:                                                      #
# Date         Name             Comments                              #
#---------------------------------------------------------------------#
# 06/14/07     m.shah           created                               #
#---------------------------------------------------------------------#

export ORACLE_SID=inrad
export TWO_TASK=INRAD
export ORACLE_HOME=/inra/inraorabin/oracle/product/10.2.0
export ORACLE_BIN=$ORACLE_HOME/bin
export ORACLE_LIB=$ORACLE_HOME/lib
export LD_LIBRARY_PATH=$ORACLE_LIB:$LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME/bin

sysdate=`date +%m%d%y`
LOGDIR=/home/fieldfin/output
LOGFILE=$LOGDIR/recip_invoice_dim_sqlldr_$sysdate.log
LDRCTLFILE=/home/fieldfin/Excel_Upload/recip_invoice_dim_data.ctl
EXLFILE=/home/fieldfin/Excel_Upload/CABS_manual_RC_$sysdate.csv

EMAIL=maitri.shah@xo.com

#------------------------------------------
# Step 1:
#
# Remove any logfiles older than n days.
#------------------------------------------
older_than_days=7

export CNT=`find $LOGDIR -mtime +$older_than_days -name "recip_invoice_dim_sqlldr*.log" -print 2>/dev/null | wc -l`
if [ $CNT -gt 0 ]
then
find $LOGDIR -mtime +$older_than_days -name "recip_invoice_dim_sqlldr*.log" -exec ls -l {} \; > /dev/null
find $LOGDIR -mtime +$older_than_days -name "recip_invoice_dim_sqlldr*.log" -exec rm {} \; > /dev/null
fi

#------------------------------------------
# Step 2:
#
# Delete 2 months old data from FIN_INVOICE_DIM only for Recip.
#------------------------------------------
$ORACLE_BIN/sqlplus -s "finance_prod/production"<<SQLEND
      spool $LOGFILE
      set serveroutput on
      exec fin_delete_invoice_dim_recip;
      spool off
      exit
      SQLEND
#------------------------------------------
# Step 3:
#
# Uses SQL Loader to transfer Recip data from CSV files to FIN_INVOICE_DIM
#------------------------------------------
sqlldr finance_prod/production control=$LDRCTLFILE DATA=$EXLFILE log=$LOGFILE

if [ $((`egrep 'SQL*Loader-500' $LOGFILE | wc -l`)) -gt 0 ]; then
   /usr/bin/mailx -s "ALERT: POSSIBLE SQL LOADER MISSING FILE ERROR - FIN INVOICE DIM RECIP DATA: INRAD" $EMAIL < $LOGFILE
elif [ $((`egrep 'ORA-' $LOGFILE | wc -l`)) -gt 0 ]; then
      /usr/bin/mailx -s "ALERT: POSSIBLE SQL LOADER ERROR - FIN INVOICE DIM RECIP DATA: INRAD" $EMAIL < $LOGFILE      
else
      #------------------------------------------
      # Step 4:
      #
      # Execute stored procedure to update some columns in FIN_INVOICE_DIM for Recip data.
      #------------------------------------------
      $ORACLE_BIN/sqlplus -s "finance_prod/production"<<SQLEND
      spool $LOGFILE
      set serveroutput on
      exec FIN_UPDATE_INVOICE_DIM_RECIP;
      spool off
      exit
      SQLEND
      if [ $((`egrep 'ORA-' $LOGFILE | wc -l`)) -gt 0 ]; then
         /usr/bin/mailx -s "ALERT: POSSIBLE ORACLE ERROR - FIN INVOICE DIM RECIP DATA: INRAD" $EMAIL < $LOGFILE
      else
        /usr/bin/mailx -s "FIN INVOICE DIM RECIP DATA: INRAD" $EMAIL < $LOGFILE
      fi
fi
return 0
Related Solutions
Related Solutions
 
Loading Advertisement...
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by maitrishah:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by anokun7:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Expert Comment by suhasbharadwaj:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Accepted Solution by Computer101:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
Loading Advertisement...
20080924-EE-VQP-40