您可以重复你的结果集如下:
SQL> select car_model from available_models
2 group by car_model ;
CAR_MODEL
------------------------------
Corsair
Executive
Country Squire
SQL>
重写你的shell脚本(使用时间)如下:
[[email protected] 1]$ cat test.sh
CONNECT='z_test/welcome1'
VALUE=`sqlplus -s /nolog <
CONNECT ${CONNECT}
set head off
select car_model from available_models
group by car_model
/
EXIT
EOF`
echo "resultset: "
echo "${VALUE}"
echo " "
echo "now iterate ..."
let rec=0
echo "${VALUE}" |while read line
do
echo "processing $rec: $line"
let rec=rec+1
done
[[email protected] 1]$
这是预期输出: