File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ # All parameters are required. This way, users can't pass empty string as parameter.
5+ invalidArgs=0
6+ [ -z " $1 " ] && invalidArgs=1
7+ [ -z " $2 " ] && invalidArgs=1
8+ [ -z " $3 " ] && invalidArgs=1
9+ [ -z " $4 " ] && invalidArgs=1
10+
11+ if [ $invalidArgs -eq 1 ]; then
12+ echo Usage: ut_run.sh " project_path" " scan_path" " sql_param_name" " output_file"
13+ exit 1
14+ fi
15+
16+ # Remove trailing slashes.
17+ projectPath=${1%/ }
18+ scanPath=$2
19+ sqlParamName=$3
20+ outputFile=$4
21+
22+ fullScanPath=" $projectPath /$scanPath "
23+
24+ if [ ! -d " $fullScanPath " ]; then
25+ echo " begin" > $outputFile
26+ echo " open :$sqlParamName for select null from dual;" >> $outputFile
27+ echo " end;" >> $outputFile
28+ echo " /" >> $outputFile
29+ exit 0
30+ fi
31+
32+ echo " declare" > $outputFile
33+ echo " l_list ut_varchar2_list := ut_varchar2_list();" >> $outputFile
34+ echo " begin" >> $outputFile
35+ for f in $( find $fullScanPath /* -type f | sed " s|$projectPath /||" ) ; do
36+ echo " l_list.extend; l_list(l_list.last) := '$f ';" >> $outputFile
37+ done
38+ echo " open :$sqlParamName for select * from table(l_list);" >> $outputFile
39+ echo " end;" >> $outputFile
40+ echo " /" >> $outputFile
Original file line number Diff line number Diff line change 1+ @ echo off
2+ setlocal EnableDelayedExpansion
3+
4+ REM All parameters are required. This way, users can't pass empty string as parameter.
5+ set invalidArgs = 0
6+ if " %1 " == " " set invalidArgs = 1
7+ if " %2 " == " " set invalidArgs = 1
8+ if " %3 " == " " set invalidArgs = 1
9+ if " %4 " == " " set invalidArgs = 1
10+
11+ if %invalidArgs% == 1 (
12+ echo Usage: ut_run.bat " project_path" " scan_path" " sql_param_name" " output_file"
13+ exit /b 1
14+ )
15+
16+ set projectPath = %~1
17+ set scanPath = %~2
18+ set sqlParamName = %~3
19+ set outputFile = %~4
20+
21+ REM Remove trailing slashes.
22+ if %projectPath:~-1 % == \ set projectPath = %projectPath:~0 ,-1 %
23+ set fullScanPath = " %projectPath% \%scanPath% "
24+
25+ if not exist " %fullScanPath% \*" (
26+ echo begin> %outputFile%
27+ echo ^ open :%sqlParamName% for select null from dual;>> %outputFile%
28+ echo end;>> %outputFile%
29+ echo />> %outputFile%
30+ exit /b 0
31+ )
32+
33+ echo declare> %outputFile%
34+ echo ^ l_list ut_varchar2_list := ut_varchar2_list();>> %outputFile%
35+ echo begin>> %outputFile%
36+ for /f " tokens=* delims= " %%a in ('dir %fullScanPath% \* /B /S /A:-D') do (
37+ set " filePath = %%a "
38+ set filePath = !filePath:%projectPath% \ =!
39+ echo ^ l_list.extend; l_list^ (l_list.last^ ) := '!filePath! ^ ';>> %outputFile%
40+ )
41+ echo ^ open :%sqlParamName% for select * from table(l_list);>> %outputFile%
42+ echo end;>> %outputFile%
43+ echo />> %outputFile%
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ clientDir=" $( dirname " $( readlink -f " $0 " ) " ) "
5+ projectDir=" $( pwd) "
6+
7+ if [[ " $clientDir " != " ${clientDir% * } " ]]; then
8+ echo " Error: ut_run script path cannot have spaces."
9+ exit 1
10+ fi
11+
12+ if [[ " $# " -eq 0 ]] ; then
13+ echo " Usage: ut_run user/password@database [options...]"
14+ exit 1
15+ fi
16+
17+ sqlplus /nolog @" $clientDir /ut_run.sql" " $clientDir " " $projectDir " " $@ "
Original file line number Diff line number Diff line change 1+ @ echo off
2+
3+ set clientDir = %~dp0
4+ set projectDir = %__CD__%
5+
6+ if not " %clientDir% " == " %clientDir: =% " (
7+ echo Error: ut_run script path cannot have spaces.
8+ exit /b 1
9+ )
10+
11+ if " %1 " == " " (
12+ echo Usage: ut_run user/password@database [options...]
13+ exit /b 1
14+ )
15+
16+ sqlplus /nolog @ " %clientDir% \ut_run.sql" '%clientDir% ' '%projectDir% ' %*
You can’t perform that action at this time.
0 commit comments