Created
September 10, 2015 11:41
-
-
Save nmrmsys/10db6e0bf1927e304258 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set echo on | |
@&1 | |
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM SQLB [FilePath] [ConStr] | |
REM デフォルト接続文字列 | |
REM SET DCS=usr/pwd@srv | |
REM SET DCS=usr:pwd:db:srv\ins | |
REM デフォルトファイルパス | |
REM SET DFP=sql\*.sql | |
REM 設定値 | |
SET LOG=log | |
SET SP=sqlplus | |
SET ST=%~dp0_start | |
SET SC=sqlcmd | |
REM 初期処理 | |
SET YMD=%date:~0,4%%date:~5,2%%date:~8,2% | |
SET HMS=%time: =0% | |
SET HMS=%HMS:~0,2%%HMS:~3,2%%HMS:~6,2% | |
SET FP=%DFP% | |
SET CS=%DCS% | |
SET DCS= | |
SET DFP= | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
REM 引数処理 | |
IF NOT "%1"=="" ( | |
SET FP=%1 | |
) | |
IF NOT "%2"=="" ( | |
SET CS=%2 | |
) | |
IF "%CS%"=="" ( | |
GOTO :USAGE | |
) | |
IF "%FP%"=="" ( | |
GOTO :USAGE | |
) | |
REM 実行処理 | |
CALL :SQLB %FP% %CS% | |
REM %~d0 | |
REM CD %~dp0 | |
REM CALL :SQLB private\func\*.sql usr1:pwd1:db:srv\ins | |
REM CALL :SQLB private\proc\*.sql usr1:pwd1:db:srv\ins | |
REM CALL :SQLB private\func\*.sql usr2:pwd2:db:srv\ins | |
REM CALL :SQLB private\proc\*.sql usr2:pwd2:db:srv\ins | |
GOTO :EOF | |
:USAGE | |
ECHO SQLB [FilePath] [ConStr] | |
GOTO :EOF | |
:SQLB | |
SET FP=%1 | |
SET CS=%2 | |
SET LP=%~dp1%LOG% | |
SET LF=%LP%\%YMD%_%HMS%.log | |
IF NOT EXIST %LP% ( | |
MD %LP% | |
ECHO. > %LP%\$$$.log | |
) | |
REM ログファイル削除 | |
FOR /f "skip=19" %%F in ('dir /b /o-n %LP%\*.log') DO ( | |
IF EXIST %LP%\%%F DEL %LP%\%%F | |
) | |
IF EXIST %LP%\$$$.log DEL %LP%\$$$.log | |
IF "%CS::=%"=="%CS%" ( | |
SET TY=ORA | |
FOR /f "delims=@ tokens=1-2" %%A in ("%CS%") DO ( | |
SET UP=%%A | |
SET SV=%%B | |
) | |
FOR /f "delims=/ tokens=1-2" %%A in ("!UP!") DO ( | |
SET US=%%A | |
SET DB=%%A | |
SET PW=%%B | |
) | |
SET TL=%SP% -S %CS% @%ST% | |
) ELSE ( | |
SET TY=SQL | |
FOR /f "delims=: tokens=1-4" %%A in ("%CS%") DO ( | |
SET US=%%A | |
SET PW=%%B | |
SET DB=%%C | |
SET SV=%%D | |
) | |
SET TL=%SC% -U !US! -P !PW! -d !DB! -S !SV! -e -i | |
) | |
ECHO [%DB%@%SV%] | |
ECHO [%DB%@%SV%] >> %LF% | |
ECHO. >> %LF% | |
REM FOR %%F in (%FP%) DO ( | |
FOR /f %%F in ('dir /b /s /on %FP%') DO ( | |
SET SF=%%~fF | |
SET CMD=%TL% %%~fF | |
ECHO !SF! | |
ECHO !SF! >> %LF% | |
REM ECHO !CMD! | |
!CMD! >> %LF% | |
ECHO. >> %LF% | |
) | |
GOTO :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment