windows限定、超小ネタです。
1.流し込みたいSQLファイルの順番をリスト化したtxtファイルを用意
list.txt
hogehoge_alter.sql
hugahuga_insert.sql
mogamoga_update.sql
そもそも、このリストを作るのが辛いって人は
コマンドプロンプト
dir *.sql /b > list.txt
みたいな感じでlist.txtを出力させましょう。
2.以下内容のbatファイルに1.で作ったlistファイルをドラッグアンドドロップ
sqlplus_injection.bat
@echo off
set user=scott
set pass=tiger
set db=orcl
set SQLPLUS=sqlplus %user%/%pass%@%db%
:init
cls
echo userを入力してください enter:%user%
set /p user=
if defined user set user=%user:"=%
echo passwordを入力してください enter:%pass%
set /p pass=
if defined pass set pass=%pass:"=%
echo dbの識別子をどうぞ enter:%db%
set /p db=
if defined db set db=%db:"=%
cls
echo user:%user%
echo password:%pass%
echo db:%db%
echo 以上の設定でよろしいですか? (やりなおし:0)
set /p input=
if defined input set input=%input:"=%
if /i "%input%" == "0" (goto init)
cls
FOR /F "" %%i IN (%1) DO @CALL :SUB %%i
goto Exit
:SUB
set args=%1
echo %args% の流し込み開始します。よろしいですか? (続ける:Enter 中止:0)
set /p input=
if defined input set input=%input:"=%
if /i "%input%" == "0" (goto Exit)
%SQLPLUS% < %args%
EXIT /B
:Exit
pause
exit
3.(゚д゚)ウマー
しかし、そろそろコマンドプロンプト(bat)芸も引退かな。