[英]Changing multiple actions chained into sqlplus to for loop in a bash script
I have this script which is obviously inefficient:我有这个显然效率低下的脚本:
#!/bin/sh
for i in $(seq 1 10);
do
echo "CREATE TABLE testbenny_$i (id NUMBER NOT NULL);
! sleep 10
select * from testbenny_$i;
! sleep 10
select * from testbenny_$i;
! sleep 10
select * from testbenny_$i;
! sleep 10
select * from testbenny_$i;
! sleep 10
DROP TABLE testbenny_$i;" | sqlplus system/passwd &
done
I have one repetitive action I tried to enclose in a FOR loop but couldn't.我有一个重复的动作,我试图将其包含在 FOR 循环中,但不能。
select * from testbenny_$i;
! sleep 10
I can't find the correct syntax to change it to a FOR.我找不到将其更改为 FOR 的正确语法。 Working on Oracle 12.
在 Oracle 12 上工作。
Try the oracle sleep
method as following:尝试 oracle
sleep
方法如下:
#!/bin/sh
for i in $(seq 1 10);
do
echo "CREATE TABLE testbenny_$i (id NUMBER NOT NULL);
sys.DBMS_SESSION.sleep(10);
Begin
For var in 1..4 loop
select * from testbenny_$i;
sys.DBMS_SESSION.sleep(10)
End loop;
End;
/
DROP TABLE testbenny_$i;" | sqlplus system/passwd &
done
I have given just an example of how to use sys.DBMS_SESSION.sleep(10)
method.我只给出了一个如何使用
sys.DBMS_SESSION.sleep(10)
方法的例子。 Use it in your code according to your requirement.根据您的要求在您的代码中使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.