If the output of sqlplus is literally "A list of integers" as you describe, then this is easy enough.
SOMETHING=5
while -r read n ; do
if [ $n -ge $SOMETHING ] ; then
break
fi
sqlplus foo/bar @test2.sql "$n"
printf '%.2f%%\n' $(expr "$n" \* 100 / "$SOMETHING")
done < sqlplus foo/bar @test.sql)
Presuming that "A list of integers" really means "A newline separated list of integers"
It's not clear to me what $testvar.x and testvar.size are supposed to represent, so I made some guesses and left the variable $SOMETHING to stand in for whatever testvar.size is supposed to be. If you want the total number of integers in the list from sqlplus then that would be different, and done like this:
intlist=($(sqlplus foo/bar @test.sql))
for n in "${intlist[@]}"; do
if [ $n -ge ${#intlist[@]} ] ; then
break
fi
sqlplus foo/bar @test2.sql "$n"
printf '%.2f%%\n' $(expr "$n" \* 100 / ${#intlist[@]})
done < sqlplus foo/bar @test.sql)
If your output is more complex some additional filtering will need to be done up front.