有没有办法运行一个shell脚本,当它更新一个sqlplus实例时会更新一秒?
代码:
echo "Please enter last name: 'input;"
read input
Statement2="INSERT INTO users VALUES ('"$input"');"
output1=$($sqlplus -s User/Pass@connection <<EOF
set head off
select count (*) from users
where fname = '$input';
EXIT;
EOF
)
read -p "User $input appears $output1 times. Create user? [Y/n]" answer
if [ -z "$answer" -o "$answer" == "y" -o "$answer" == "Y" ]
then
$sqlplus -s User/Pass@connection << Eossql
set autocommit on
set head off
$Statement2
quit;
Eossql
else
echo "Not creating user"
fi
如果最终用户选择(y)
,如何使用单独的用户标识和密码更新第二个sqlpus实例?谢谢!
答案 0 :(得分:1)
您可以将SQL代码保存为在变量中的两个实例上运行,然后重复使用它:
sql=$(cat << EOF
set autocommit on
set head off
$Statement2
quit;
EOF
)
$sqlplus -s User/Pass@connection <<< "$sql"
$sqlplus -s User2/Pass2@connection2 <<< "$sql"