The thing is that it overwrites in Result.txt and I only get the last query. How can I fix this?

while read -r line
  echo "'$line'"
  sqlplus -s whatever/whatever <<-EOF
  SPOOL Result.txt
  SELECT * FROM ---- WHERE sol = '$line';
  SPOOL OFF ;   

done < evs.txt

just add

 rm Results.txt

before the loop


 cat Result.txt >> Results.txt

after EOF (and before done).

  • Thanks but now there is sth wierd happening, now I get "no rows selected" in Results.txt and in the shell I get cat: Resultado3.txt: Source is same as Target. Skipping... – lucia Sep 2 '15 at 9:12
  • "No Row selected" means query return no row. have you typed cat as mention in my answer ? – Archemar Sep 2 '15 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.