0

我有带有以下代码的shell脚本:

#! /bin/bash

MODEL=$1
declare -a arr=("porsche" "lamborgini" "tesla")

for i in ${arr[@]}
do
sqlplus -s un/pass <<!
set verify off
INSERT INTO tbl1 (par1, par2, par3, datetime_parm)
VALUES('$MODEL', '${arr[i]}', (select count(s) from table i), SYSTIMESTAMP);
COMMIT;
exit;
!
done

出于某种原因,它覆盖了它从数组中获取的先前值,而我最终只用“tesla”填充表。

有谁知道我做错了什么?

4

1 回答 1

1

我想到了。

#! /bin/bash

MODEL=$1
declare -a arr=("porsche" "lamborgini" "tesla")

for i in ${arr[@]}
do
sqlplus -s un/pass <<!
set verify off
INSERT INTO tbl1 (par1, par2, par3, datetime_parm)
VALUES('$MODEL', '$i', (select count(s) from table i), SYSTIMESTAMP);
COMMIT;
exit;
!
done
于 2013-11-14T19:00:14.310 回答