Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute SQL command in multiple instances with Bash script.

Praveen PoluSep 4 2016 — edited Sep 7 2016

How can I run below SQL commands even after exit from Instance=ABC with one bash script ? I want to execute below procedure in multiple instances. It is working till "EXIT" forĀ  SID=ABC but I want it to continue for next Instance=DEF. Any suggestions would be of great help, Thank you in advance.

Oracle Linux Server release 5.11

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

!/bin/bash

echo $ORACLE_SID

ORAENV_ASK=NO

ORACLE_SID=ABC

. oraenv

sqlplus / as sysdba << EOF

set time on echo on

select '-- ABC --' from dual;

spool terminate_ABC_USER1.out

exec TERMINATION_REQUEST('USER1');

spool off

EXIT;

echo $ORACLE_SID

ORAENV_ASK=NO

ORACLE_SID=DEF

. oraenv

sqlplus / as sysdba

set time on echo on

select '-- DEF --' from dual;

spool terminate_DEF_USER2.out

exec TERMINATION_REQUEST('USER2');

spool off

EXIT;

done

EOF

This post has been answered by handat on Sep 4 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2016
Added on Sep 4 2016
11 comments
2,965 views