Link to home
Start Free TrialLog in
Avatar of dplinnane
dplinnaneFlag for United States of America

asked on

Staring multiple sqlplus sessions from a shell script

I wrote the following shell script to start multiple sqplus sessions running the same procedure. But is running one procedure after the other and not creating a new session, how do I make my script creat a new session? Thanks in advance.
 [oracle@linux3 scripts]$ sqlplus_proc_in1.sh 'simulate_workload_with_binds(2000)'

0 [oracle@linux3 scripts]$ sqlplus_proc_in1.sh 'simulate_workload_with_binds(2000)'
Enter the number of sessions
3

PL/SQL procedure successfully completed.

0
PL/SQL procedure successfully completed.

1
PL/SQL procedure successfully completed.



#!/bin/ksh

echo "Enter the number of sessions"
read session

num=0                   # Initialize num
while (( $num < $session ))   # or  while [ num -lt 10 ]
do

#if exit; is not here there will be no result printed to the screen
$ORACLE_HOME/bin/sqlplus -s admin/limk1234 <<EOF
begin
$1;
end;
/

EOF
      echo  -n "$num "
      let num+=1           # Increment num
done
exit;
echo -e "\nAfter loop exits, continue running here"
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You will need to submit your sqlplus sessions as a background process or you will need to spawn a child process

To submit it in background use this
$ORACLE_HOME/bin/sqlplus -s admin/limk1234 <<EOF
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dplinnane

ASKER

excellent I was so close Thanks
Just a quick question.
What is the difference between sessions and threads? are they the same?  
Session could mean different things in different context. Generally session refers to a shell instance in the context you probably are asking. Thread is a subunit in a process. A process could have multiple threads.