Sie sind auf Seite 1von 3

/* Formatted on 9/24/2010 1:20:26 PM (QP5 v5.149.1003.

31008) */
#!/bin/bash

login_usr_pwd=apps/apps

cd $XXNSN_TOP/bin

echo "Inside shell script xxnsnWIFile.sh"

echo "Creating file containing the list of Work Item dynamically !!!"

VALUE=`sqlplus -s $login_usr_pwd<<File
SET FEEDBACK OFF VERIFY OFF ECHO OFF HEADING OFF pages 0 linesize 150 long 9999999
head off
SPOOL STFilename

SELECT IST.STRATEGY_NAME
FROM IEX_STRATEGY_TEMPLATES_B ISTB, iex_strategy_templates_tl IST
WHERE ISTB.STRATEGY_TEMP_ID = IST.STRATEGY_TEMP_ID
AND IST.STRATEGY_NAME LIKE 'XXNSN%'
AND ISTB.enabled_flag = 'Y';

SPOOL OFF;
EXIT;
FILE`

IF [ -z "$value" ]; then
echo "No rows returned from database"
exit 0
ELSE
echo $value
fi

echo "Creating one file per Stragegy..."

cat STFilename.lst | while read strategy

DO
echo "Strategy: $strategy"
strategyFileName=`echo $strategy | tr -d ' ' | tr -d '-'`.csv
sqlplus -s $login_usr_pwd<<BAR
host echo "Inside sqlplus....."
SET FEEDBACK OFF VERIFY OFF ECHO OFF HEADING OFF pages 0 linesize 150 long 9999999
head off
spool $strategyFileName

SELECT DECODE (str_temp.STRATEGY_NAME,


'XXNSN Complete barring Collections Strategy', 'SUSPENSION',
'SERVICE SUSPENSION')
|| ','
|| sa.attribute6
|| ','
|| stry_temp_wkitem_tl.description
|| ','
FROM iex_strategy_work_items wkitem,
iex_stry_temp_work_items_b stry_temp_wkitem_b,
iex_stry_temp_work_items_tl stry_temp_wkitem_tl,
iex_strategies str,
iex_strategy_templates_tl str_temp,
iex_dln_uwq_summary dlq,
hz_cust_accounts ba,
hz_cust_accounts sa
WHERE ba.account_number = sa.attribute5 AND sa.attribute16 <> 'FAMILY'
AND wkitem.work_item_template_id =
stry_temp_wkitem_b.work_item_temp_id
AND stry_temp_wkitem_b.work_item_temp_id =
stry_temp_wkitem_tl.work_item_temp_id
AND wkitem.status_code IN ('OPEN', 'PRE-WAIT')
AND wkitem.strategy_id = str.strategy_id
AND str.strategy_template_id = str_temp.strategy_temp_id
AND str.status_code IN ('OPEN', 'ONHOLD')
AND str.object_type = 'ACCOUNT'
AND dlq.cust_account_id = ba.cust_account_id
AND str.cust_account_id = ba.cust_account_id
AND str_temp.STRATEGY_NAME = '$strategy';

spool off;
exit;
BAR
done

echo "Creating file to UNBAR the services"


sqlplus -s $login_usr_pwd<<UNBAR
SET FEEDBACK OFF VERIFY OFF ECHO OFF HEADING OFF pages 0 linesize 150 long 9999999
head off
spool XXNSN_UNBAR_SERVICES.csv

SELECT 'SERVICE RESUME'


|| ','
|| sa.attribute6
|| ','
|| stry_temp_wkitem_tl.description
FROM iex_strategy_work_items wkitem,
iex_stry_temp_work_items_b stry_temp_wkitem_b,
iex_stry_temp_work_items_tl stry_temp_wkitem_tl,
iex_strategies str,
iex_strategy_templates_tl str_temp,
iex_dln_uwq_summary dlq,
hz_cust_accounts ba,
hz_cust_accounts sa
WHERE ba.account_number = sa.attribute5 AND sa.attribute16 <> 'FAMILY'
AND wkitem.work_item_template_id =
stry_temp_wkitem_b.work_item_temp_id
AND stry_temp_wkitem_b.work_item_temp_id =
stry_temp_wkitem_tl.work_item_temp_id
AND wkitem.status_code IN ('CLOSED', 'TIMEOUT')
AND wkitem.strategy_id = str.strategy_id
AND str.strategy_template_id = str_temp.strategy_temp_id
AND str.object_type = 'ACCOUNT'
AND dlq.cust_account_id = ba.cust_account_id
AND str.cust_account_id = ba.cust_account_id
AND str.status_code = 'CLOSED';

spool off;
exit;
UNBAR
rm -f STFilename.lst

Das könnte Ihnen auch gefallen