|
原帖由 sqysl 于 2008-6-1 04:13 发表 ![]()
thanks to yonghuang,but what is your mean for the "Actually, we probably could merge all contents of $i.sql into the single file, test.sh, using here documents",how to put all into the single file?like this:
$cat crt_sql_test.sh
#!/bin/sh
i=1
while [ i -le 48 ]
do
echo "sqlplus -S yong/yong set transaction use rollback segment "_SYSSMU5$";delete from t where x = $i &">>test.sh
i=`expr $i+1`
done
Instead of having many .sql files, each one called by
sqlplus -s yong/yong @$i.sql &
I can do this:
$ cat test.sql
set transaction use rollback segment "_SYSSMU11$";
delete from t where x = &1;
$ cat test.sh
sqlplus -s yong/yong @test 1 &
sqlplus -s yong/yong @test 2 &
sqlplus -s yong/yong @test 3 &
sqlplus -s yong/yong @test 4 &
sqlplus -s yong/yong @test 5 &
sqlplus -s yong/yong @test 6 &
sqlplus -s yong/yong @test 7 &
sqlplus -s yong/yong @test 8 &
...
$ . ./test.sh
That works. But it's still not ideal. I want to merge the test.sql into test.sh so one single file is enough. I haven't figured that out yet.
By the way, in your script you need to change echo to echo -e, add spaces around + inside expr expression, remove in front of &, and change "i -le 48" to "$i -le 48". I like the new syntax better: while (( i < 48 )).
Also, you need to run the shell script as a dot script: . ./test.sh, not just ./test.sh.
Yong Huang |
|