[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4549
  • Last Modified:

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"
0
dplinnane
Asked:
dplinnane
  • 2
  • 2
  • 2
2 Solutions
 
amit_gCommented:
Change

$ORACLE_HOME/bin/sqlplus -s admin/limk1234 <<EOF

to

$ORACLE_HOME/bin/sqlplus -s admin/limk1234 <<EOF &
0
 
sathyagiriCommented:
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
0
 
sathyagiriCommented:
Oops missed the &
$ORACLE_HOME/bin/sqlplus -s admin/limk1234 <<EOF &
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
dplinnaneAuthor Commented:
excellent I was so close Thanks
0
 
dplinnaneAuthor Commented:
Just a quick question.
What is the difference between sessions and threads? are they the same?  
0
 
amit_gCommented:
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.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now