我使用以下简单的UNIX脚本将输出分配给变量。
count=`sqlplus -s ${DB_USER}/${DB_PASS}@${DB_INST} << END
SELECT COUNT(column_name) from table_name;
END`
echo $count
但是我在执行时遇到以下错误:
SP2-0042: unknown command "END" - rest of line ignored.
count =`sqlplus -s $ {DB_USER} / $ {DB_PASS} @ $ {DB_INST}&lt;&lt; END
当我尝试在putty中执行上述语句时,它说是&#34;糟糕的替换&#34;
所以我使用UNIX脚本将输出分配给变量。
计数= sqlplus DB_USER/DB_PASS << END
SELECT VERSION_NUMBER from GA_PERIODIC_REFRESH where MODULE_NAME in 'RoaminfoService';
exit;
END
echo $ count
答案 0 :(得分:3)
您还需要exit
:
count=`sqlplus -s ${DB_USER}/${DB_PASS}@${DB_INST} <<END
set pages 0 echo off feed off
SELECT COUNT(column_name)
exit;
END`