batch file - variable was unexpected at this time -
i'm not familiar bat files have file runs sqlplus query, returns row count, , if greater 0, run bat file. feel i'm there keep getting error:
%%a unexpected @ time
@echo off /f "delims=" %%a in ( 'sqlplus user/pass@omp1 @voiceblocktrig.sql' ) set rowcount=%%a if %rowcount% gtr 0 ( c:\sqltriggers\voiceblkautoationbat.bat ) when run above, reponse:
@echo off /f "delims=" %%a in ( %%a unexpected @ time 'sqlplus user/pass@omp1 @voiceblocktrig.sql' ''sqlplus' not recognized internal or external command, operable program or batch file ) set rowcount=%%a if %rowcount% gtr 0 ( more? c:\sqltriggers\voiceblkautoationbat.bat more? when run this:
sqlplus user/pass@p1 @voiceblocktrig.sql i integer value too
why there such gap between set , rowcount?
in itself, it's of no matter - suspect have them on separate lines.
the set rowcount=%%a must on same physical line do - , do must on same physical line closing parenthesis after in
for /f "delims=" %%a in ( 'sqlplus user/pass@p1 @voiceblocktrig.sql' ) set rowcount=%%a if legitimate.
as .bat file:
:: @echo off echo starting sqlplus sqlplus user/pass@omp1 @voiceblocktrig.sql echo finished sqlplus /f "delims=" %%a in ( 'sqlplus user/pass@omp1 @voiceblocktrig.sql' ) echo(+%%a+&set /a rowcount=%%a echo rowcount=+%rowcount%+ if %rowcount% gtr 0 ( c:\sqltriggers\voiceblkautoationbat.bat ) pause this batch appears close you'd need run.
the changes are:
- added
echo(+%%a+inforloop. - the open-parenthesis following echo character has been found better space separate
echotext-to-be-echoed
- the open-parenthesis following echo character has been found better space separate
- the
+before , after %%a delimits string obvious character presence of spaces can more observed.
- the
setchangedset /ainterprets value assigned numeric-string, should overcome stray spaces in assignment.- added
echoof rowcount within delimiters visibility - added pause stop procedure closing before have chance see results.
comment : "delims=" not required, we'll when problems defeated.
comment: report script required 2 enters mean sqlplus asking input. if so, 'echo.^|sqlplus... may alleviate problem.
if sqlplus batch, different approach need made.
further changes attempt solve puzzing result:
- double-colon before @echo off - double-colon used comment. object show lines being executed.
- added sqlplus command independently - observe results.
- added 2 echo lines display progress.
certainly odd....
Comments
Post a Comment