我想寫一個bash函數,它應該刪除table1中的一些條目,如果用戶輸入1,否則刪除不同的條目。我的功能看起來是這樣的:如何在bash中執行sqlplus?
function reset_db
{
if [ $usr_input == 1 ]
then
sqlplus -s $USR/[email protected]$SID << EOF
delete from table1 where component = 'ABC';
delete from table2 where component = 'ABC';
exit
EOF
else if [ $usr_input == 2 ]
delete from table1 where component = 'XYZ';
delete from table2 where component = 'XYZ';
exit
EOF
fi
}
我得到錯誤:附近意外的標記'科幻」
我相信,它正在發生,因爲我使用的if-else不正確的地方,但不是語法錯誤能夠找出解決方法。
也請讓我知道如果我有任何更多的後續問題,我怎麼能在同一個線程下發布代碼。
請不要使用「謝謝」你的問題。這是無用的噪音。 – Doorknob 2013-02-25 19:47:10