This is a faily lengthly script. It moves a file from a mainframe to a Unix box, and updates an Oracle interface table. The data is pulled from the table by an oracle application job at a later time. The part of the script that is not working the the part that prevents duplicate entires from being in the interface table. We moved from HP-UX to AIX a few years ago, and I had to modify a lot of scripts, mostly just syntax. I don't know why I can't seem to get my hands around this. Here is some of the code.
# ***************************************************************
# copy the file from the staging area
echo " "
echo "Creating a new file: $MAINT_DB-$FILE_NAM.new"
echo "working...."
echo "working......"
cp $FROM_DIR/$FILE_NAM.001 $TO_DIR/$MAINT_DB-$FILE_NAM.tmp
STATUS=$?
if [ "$STATUS" != 0 ]
then
echo "The file copy from the Mainframe failed. Notify Tech Support." >> $MAINT_LOGS/$LOG_FL
echo "The file copy from the Mainframe failed. Notify Tech Support."
exit;
fi
fi;
# get header records
grep "*TOTAL*" $TO_DIR/$MAINT_DB-$FILE_NAM.tmp > gl_file.tmp1
COUNT_HD=`cat gl_file.tmp1 | cut -c3-9 | grep "*TOTAL*" | wc -l`
if [ "$COUNT_HD" = 0 ]
then
echo "The file copied from the Mainframe has no header record. Notify Tech Support." >> $MAINT_LOGS/$LOG_FL
echo "The file copied from the Mainframe has no header record. Notify Tech Support."
exit;
fi
DETAILS=`expr $TOT_NUM - $COUNT_HD`
# get detail records (all not *TOTAL*)
# grep -v "***TOTAL***" $TO_DIR/$MAINT_DB-$FILE_NAM.tmp > $TO_DIR/$MAINT_DB-$FILE_NAM.new
TOT_REC=`wc -l < $TO_DIR/$MAINT_DB-$FILE_NAM.new`
echo " "
echo "The GL data $COPY_MES to $TO_DIR as $MAINT_DB-$FILE_NAM.new."
echo "$TOT_REC records are ready to be loaded to the gl_interface table."
# echo "Do you want to proceed? y/n: "\\c
# read yn rest_of_line
# case $yn in
# [Yy]) : ;;
# * ) exit 1;;
# esac
# ********************************************************************
# check for duplicate records already on the gl_interface table
# start a loop to get each header record
echo "The following SOURCE and GROUP-ID sets were on the file." >> $MAINT_LOGS/$LOG_FL
echo "SOURCE GROUP ID COUNT" >> $MAINT_LOGS/$LOG_FL
i=1
j=$COUNT_HD
while [ "$i" -le $COUNT_HD ]
do
# get next header record
HEADER1=`head -n1 gl_file.tmp1 | cut -c1-10`
SOURCE1=`head -n1 gl_file.tmp1 | cut -c17-26`
GROUP1=`head -n1 gl_file.tmp1 | cut -c34-41`
COUNT1=`head -n1 gl_file.tmp1 | cut -c27-32`
check the gl_interface table to prevent reloading same data.
# delete all rows with matching source and group id
sqlplus gl/$USER_PW @$DHEC_SQL/dhgl_interface_delete.sql $SOURCE1 $GROUP1;
rem delete rows from gl_interface table for existing value to prevent loading same data again.
rem source name and group id are passed from transfer script
rem set term off;
rem set echo off;
rem set heading off;
rem set feedback off;
delete from gl_interface
where user_je_source_name = '&1 &2' and group_id = '&3';
commit;
exit;
Is the problem that the records don't get deleted?
After a quick glance the script looks reasonable... have you verified that the column numbers for you 'cut' commands are correct? That is, do the lines getting written to the log file look right? And are these records actually deleted from the DB?
Not being someone who uses sqlplus, I am really just guessing, but I suspect that there might be some characters in your removal line that need escaping, or perhaps it might work to do a block quote. When in doubt, I block-quote. IBM Certified -- AIX 4.3 Administration
IBM Certified -- AIX 4.3 Support
IBM Certifiable!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.