我已经对此进行了彻底的搜索,但我无法找到所有的部分;
我有:
BatchA runs for loop
Calls BatchB
BatchB runs a SQL script
SQL Script raises error
BatchB gets error, does (exit /b %ErrorLevel%)
Batch A checks for error
我无法完成最后一步,其中 BatchA 响应批处理 B 的退出错误。
我已经简化了它,我什至无法让以下工作。不工作,我的意思是 GOTO 语句不执行。我讨厌批量循环!!!!
批次A
setlocal enabledelayedexpansion
FOR /L %%i IN (0,1,0) DO (
:: Define variables
CALL SET TEST_NAME=%%TESTS[%%i]%%
CALL SET D_TEST=%%D_TESTS%%\%%TEST_NAME%%
CALL SET D_DB_RAW=%%D_TEST%%
CALL SET P_TEST=%%D_TEST%%\%%TEST_NAME%%.bat
:: Run preparation script
CALL ECHO. && ECHO.
CALL ECHO [INFO] TEST: %%TEST_NAME%%
CALL ECHO ----------------------------------------------------------
CALL ECHO [INFO] PREPARING THE DATABASE
CALL PUSHD %%D_PRE_TEST%%
CALL %%P_PRE_TEST_BAT%% %%D_DB%% %%D_DB_RAW%%
CALL POPD
CALL SET ERR_MSG="Error preparing the database before test: %%TEST_NAME%%"
if !ERRORLEVEL! NEQ 0 GOTO L_ERROR
B批次
EXIT /b 1