1

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.

  select * from testbenny_$i;
  ! sleep 10

I can't find the correct syntax to change it to a FOR. Working on Oracle 12.

2

1 Answer 1

1

Try the oracle sleep method as following:

#!/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. Use it in your code according to your requirement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.