Try this:
Code:
#!/usr/bin/ksh
while read country count; do
### try to login to oracle and set some error condition
if [ #the failure condition is set ]; then
count=$(($count+1))
fi
echo $country $count >> your_file.tmp
done < your_file
mv your_file.tmp your_file
Some of the script is not real code, because I am not sure how you are going to check if you can connect to the database.