这是我的数组:
orlist=""
orlist="T_TAB1 \n"
orlist=$orlist"T_TAB2 \n"
orlist=$orlist"T_TAB3 \n"
orlist=$orlist"T_TAB4 \n"
echo $orlist
arrIdx=0
OLD_IFS=$IFS;
IFS="\n"
for IndixList in ${orlist[@]};
do
echo $IndxList
MYDIR[${arraryIndix}]=$IndixList
(( arraryIndix = $arraryIndix+ 1 ))
done
IFS=$OLD_IFS
我必须在 for 循环内的 oracle db 中执行 SELECT,所以我必须按选项卡读取 $orlist 选项卡。我已经尝试过了,但它不起作用它需要整个数组而不是一个标签一个标签:
for arraryIndix in ${orlist[@]};
do
echo "SET HEADING OFF" >> ${FILEOR_SQL}
echo "SET TERMOUT OFF" >> ${FILEOR_SQL}
echo "SET PAGESIZE 0" >> ${FILEOR_SQL}
echo "SET LINESIZE 1000" >> ${FILEOR_SQL}
echo "SET FEEDBACK OFF" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL ON" >> ${FILEOR_SQL}
echo "SPOOL ${FILE_DAT}" >> ${FILEOR_SQL}
echo "SELECT * " >> ${FILEOR_SQL}
echo "FROM ${orlist[@]}" >> ${FILEOR_SQL}
echo "WHERE REP_ARG = 2; " >> ${FILEOR_SQL}
echo "SPOOL OFF" >> ${FILEOR_SQL}
echo "COMMIT;" >> ${FILEOR_SQL}
echo "SET HEADING ON" >> ${FILEOR_SQL}
echo "SET TERMOUT ON" >> ${FILEOR_SQL}
echo "SET PAGESIZE 14" >> ${FILEOR_SQL}
echo "SET FEEDBACK ON" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL OFF" >> ${FILEOR_SQL}
echo "EXIT;" >> ${FILEOR_SQL}
sqlplus -S -L ${Connection} @${FILEOR_SQL} #connection is a var for connect with `sqlplus`
done
有什么建议么?提前致谢