# IBM Confidential
# OCO Source Materials
# 5724-V51
#
# (c) Copyright IBM Corp. 2000, 2008 All Rights Reserved.
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.

#!      /bin/sh

#	Copyright 2007, IBM Corporation


#      dodeletecet.sh - Delete the rows for one source catalog from the CET_BADBLOB table

# Usage of the file
if [[ $# -ne 4 ]]
then
 echo "Usage "
 echo "dodeletecet.sh --db=databasename --dbuser=dbusername --dbpassword=dbuserpassword --srcCtgId=srcctgid"
 echo "Example dodeletecet.sh --db=wpcdb --dbuser=wpc1 --dbpassword=wpc1 --srcCtgId=6"
 
 exit 0
fi

# Declare the variables
DBName=`echo $1 |cut -d "=" -f2`;export DBName
DBUSER=`echo $2 |cut -d "=" -f2`;export DBUSER
DBUserPassword=`echo $3 |cut -d "=" -f2`;export DBUserPassword
SrcCtgId=`echo $4 |cut -d "=" -f2`;export SrcCtgId

# unused
--deleteFile="${SrcCtgId}-{`date |awk '{print "deletereport_item_ca_"$2"_"$3"_"$6"_"$4}'|sed s/":"//g`-.txt";export deleteFile

sed s/"srcCtgId"/"${SrcCtgId}"/ delete_src_ctg_from_cet.sql > delete_scratch.sql

sqlplus ${DBUSER}/${DBUserPassword}@${DBName} <<EOF

set heading off
set line 100000
set wrap off
set newpage NONE

--spool ${deleteFile}

-- compile procs
@procs

-- delete
@delete_scratch

EOF

rm delete_scratch.sql

#if [ "$TOP" ]
#then
#mv ${deleteFile}  ${TOP}/logs/deleteLog
#else
#mv ${deleteFile}  logs/deleteLog
#fi

exit $?
