i have a script that will retrive some info from database. The script is working fine but i have to add new feature in it when the script fails or retrive null result it should reflect in the log file.
below the script AMR_Inactive.sh
Code:
while read i
do
connect1=`sqlplus -silent amit/qwerty@edna.world <<END
set pagesize 0 feedback off verify off heading off echo off
SELECT meter.X_UDC_ASSET_ID
FROM
SIEBEL.S_ASSET Meter,
SIEBEL.S_ASSET SDP,
SIEBEL.s_asset_rel ARSM,
SIEBEL.S_ADDR_PER Premise,
SIEBEL.S_ASSET Route,
SIEBEL.s_asset_rel ARSR
WHERE
ARSM.par_asset_id = SDP.row_id AND
ARSM.asset_id = Meter.row_id AND
ARSM.relation_type_cd = 'SDP-METER' AND
ARSM.x_rel_status = 'Active' AND
SDP.PER_ADDR_ID = Premise.row_id AND
ARSR.par_asset_id = Route.row_id AND
ARSR.asset_id = SDP.row_id AND
ARSR.relation_type_cd = 'ROUTE-SDP' AND
ARSR.x_rel_status = 'Active' AND
Premise.X_CLIENT_PRMSE_ID = '$i';
exit;
END`
echo "Completed for $i"
echo "$connect1"
done < TNS_AMRI_INACTIVE.txt
contents of TNS_AMRI_INACTIVE.txt
if suppose for this data the script returns null result i should get the info "No rows returned" in my log file.i m runnig the script using crontab
AMR_Inactive.sh > AMR_Inactive.log 2>&1