Trying to compile all SQL files using a shell script. But the below code is not working. Below Code works fine when for loop is not there(commenting line no: 1,2 and 9).
1. sq_lfile=`ls *.sql`
2. for current_sql_file in $sql_file
3. do
4. sqlplus uname/pass@Service>>SQLLOG << -ENDOFSQL
5. spool DATA_FILE.DAT
6. @ $current_sql_file
7. spool off
8. exit;
9. ENDOFSQL
10. done
Thanks for reply edstertec. Your one line script is working fine. The variable name mistake was just a typo mistake. In actuall script it is fine. However 'm trying with my code but giving below error:
syntax error at line 18: `end of file' unexpected
If you could tell me why this error is coming that will be really great and helpful for me.
Is that heredoc redirection a typo as well? Judging from the use of "ENDOFSQL" later in the script, you do not want to use the word "-ENDOFSQL", so I assume that's a typo of: