Reputation: 139
I made a batch script that iterates recursively through all the .sql files under a directory. My problem is that i can echo all the files treated correctly with this version :
@for /r "%PWD%\06-Instalaciones" %%a in (*.sql) do (IF "C:%%~pa" NEQ "%PWD%06-Instalaciones\ProximaInstalacion\" echo %%~fa )
But i cant seem to sucessfully call SqlPlus instead of the echo, for every sql file treated :
@for /r "%PWD%\06-Instalaciones" %%a in (*.sql) do (IF "C:%%~pa" NEQ "%PWD%06-Instalaciones\ProximaInstalacion\" %ORACLE_HOME%/bin/sqlplus -L -S FOO/BAR@%sid% @%%~fa)
I get the following error : "(HOST was unexpected at this time.".
Thank you.
Upvotes: 0
Views: 1028
Reputation: 139
Thanks to angus for pointing out my error. I had a space in one of my variables!!! Particularly in %sid%. I'll leave here my code in case someone needs it :
@echo off
@SET PWD=%~dp0
@SET sid=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SID=xxxxx)))
@for /r "%PWD%\06-Instalaciones" %%f in (*.sql) do (IF "C:%%~pf" NEQ "%PWD%06-Instalaciones\ProximaInstalacion\" %ORACLE_HOME%/bin/sqlplus -L -S FOO/BAR@"%sid%" @%%~f >> log.txt)
Upvotes: 1