
#! /bin/bash

. ${TOP}/bin/get_params.sh

#. ${TOP}/src/db/schema/util/set_db.sh \
#    --db_user_name=${_CCD_DB_USER_NAME} \
#    --db_user_pwd=${_CCD_DB_USER_PWD} \
#    --db_service_name=${_CCD_DB_SERVICE_NAME}

. ${TOP}/src/db/schema/util/set_db.sh \
    --db_user_name=bbuynov28 \
    --db_user_pwd=bbuynov28 \
    --db_service_name=supdb

echo 'CONNECTION: ' $CONNECTION
echo 'DATE: ' $_CCD_DATE
echo 'COMPANY ID: ' $_CCD_CMPID

${CCD_SQLPLUS} ${CONNECTION} <<EOF > /tmp/ctg-check.out 2>&1
set pagesize 0;
set linesize 200;
select cit_container_id, 'COLLAB_AREA' 
where cit_container_id = ctg_id
and ctg_type = 'COLLABORATION_AREA';
commit;
EOF

# Need to check /tmp/ctg-check.out for colloab area catalogs

${CCD_SQLPLUS} ${CONNECTION} <<EOF > /tmp/itm.sql 2>&1
set pagesize 0;
set linesize 200;
set head off;
set feedb off;
prompt 
select 
'delete from itm where ITM_CONTAINER_ID = ' || to_char(cit_container_id) ||
' and ITM_ID = ' || to_char(cit_entry_id) || ' ;' 
from cit
commit;
EOF

${CCD_SQLPLUS} ${CONNECTION} <<EOF > /tmp/icm.sql 2>&1
set pagesize 0;
set linesize 200;
set head off;
set feedb off;
prompt 
select 
'delete from icm where ICM_CATALOG_ID = ' || to_char(cit_container_id) ||
' and ICM_ITEM_ID = ' || to_char(cit_entry_id) || ' ;' 
from cit
commit;
EOF

cd /tmp
${CCD_SQLPLUS} ${CONNECTION} <<EOF 2>&1
set head off;
set feedb on;
@itm
@icm
commit;
EOF


