利用下面的BAT脚本,自动批量执行Oracle SQL脚本。
::chunyu.wu
if exist 01_RUN.log del 01_RUN.log
if exist 1.txt del 1.txt
echo SET DEFINE OFF >> 1.txt
echo SPOOL 01_RUN.log >> 1.txt
for %%i in (*.sql) do (echo PROMPT %%i >> 1.txt
echo @%%i >> 1.txt
)
echo SPOOL OFF >> 1.txt
echo EXIT; >> 1.txt
cls
color 0a
@ECHO OFF
mode con cols=120 lines=30
TITLE TEST
@ECHO ON
CLS
SQLPLUS USERNAME/PASSWORD@IP:PORT/SERVICENAME @1.txt
@ECHO OFF
del 1.txt
cls
type 01_RUN.log | find "エラー" && color 4f && echo 詳しいエラー内容は01_RUN.logを参照ください。 && pause && exit
REM notepad 01_RUN.log
del 01_RUN.log
echo WScript.sleep 5000 > sleep.vbs
color 2f
@echo.
@echo --------------------------
@echo 成功!!!、5秒後で退出。
@echo --------------------------
rem pause
Wscript sleep.vbs
if exist sleep.vbs del sleep.vbs