Little help please

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Little help please

Julie
Hi Erman!
Pls take a look.. Do you see any erros ? Logical flow ?

This shell script I need  to put to the cron starting from 19:00 -20:00
IF it finds the row ->updates it straight way and quite for good,
If it doesn not, it seraches every 2 min and for 1 hour and then quite completely.

========================
while(true);
do    
starttime=`date +%s`
end=$((starttime+3600))    
while [[ $((`date +%s` - $starttime)) -lt 120 ]]; do
 if [ `date +%s`-eq $end ]; then
break
fi        
  rows=`sqlplus -s<< EOF
  apps/xxxx              
  whenever sqlerror exit 1
  SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF            
  select count(1)
  from xxx where condition='123';
  EOF`        

if [ $rows -neq 0] ;
then
sqlplus -s  << EOF1
apps/xxxx
update xxx set hold='Y' where
condition='123';
commit;
EOF1
echo "Done."
exit 0;
else        
echo "once more."        
fi    
done
done
========
Thanks,Julie
Reply | Threaded
Open this post in threaded view
|

Re: Little help please

ErmanArslansOracleBlog
Administrator
Hi Julie,

1)Why don't you directly update the rows? (rather than checking using select)
A row can be inserted in the time interval between your check and your update.

2)Your script is working with the seconds.
What will happen if your update will hang or will take some time to complete? Can you tolerate this? (I mean the business rules)

3)Why don't you do the time calculations in db? It sounds better because the real work is in db and the time calculation should be closer to the place where the work is done.. (this may supply a more guaranteed time-work coordination)