Oracle 循环中的sqlplus-unix
是否有一种方法可以在一个循环中发送多个sqlplus命令,但要等待其中一个命令成功运行才能启动下一个命令? 这是我的代码示例。我尝试添加sleep 15,因为我将要执行的函数需要10-20秒才能运行。我想去掉15s常数,让它们一个接一个地运行Oracle 循环中的sqlplus-unix,oracle,shell,unix,plsql,sqlplus,Oracle,Shell,Unix,Plsql,Sqlplus,是否有一种方法可以在一个循环中发送多个sqlplus命令,但要等待其中一个命令成功运行才能启动下一个命令? 这是我的代码示例。我尝试添加sleep 15,因为我将要执行的函数需要10-20秒才能运行。我想去掉15s常数,让它们一个接一个地运行 if [ "$#" -eq 1 ]; then checkUser "$1" while read line; do sqlplus $user/$pass@$server $line sleep 15 done &l
if [ "$#" -eq 1 ]; then
checkUser "$1"
while read line; do
sqlplus $user/$pass@$server $line
sleep 15
done < "$wrapperList"
fi
if[“$#”-等式1];然后
选中用户“$1”
读行时;做
sqlplus$user/$pass@$server$line
睡眠15
完成<“$wrapperList”
fi
循环中的指令按顺序执行。这相当于使用这样做代码>链接说明:
sqlplus $user/$pass@$server $line1
sqlplus $user/$pass@$server $line2
因此这里不需要sleep 15
,因为sqlplus
命令不会被并行调用。你已经这样做了,一个接一个地给他们打电话
备注:如果第一行没有正确返回,最好停止运行,使用&&
表示:仅当前面的返回代码为0
sqlplus $user/$pass@$server $line1 &&\
sqlplus $user/$pass@$server $line2
要使其在while循环中,请执行以下操作:
checkUser "$1"
while read line; do
sqlplus $user/$pass@$server $line
RET_CODE=$? # check return code, and break if not ok.
if [ ${RET_CODE} != 0 ]; then
echo "aborted." ; break
fi
done < "$wrapperList"
检查用户“$1”
读行时;做
sqlplus$user/$pass@$server$line
RET_代码=$?#检查返回代码,如果不正常则中断。
如果[${RET_CODE}!=0];然后
回声“中止”;打破
fi
完成<“$wrapperList”
另一方面,当您想要并行运行时,语法是不同的,比如这里:哦,我以为它将并行发送sqlplus命令。这只是将在sqlplus命令中使用的.sql文件的列表。没有尝试,这是我的第一个假设。我会努力的,我会给你一个答案。谢谢