I've inherited a shell script that has imbedded calls to sqlplus throughout. Often the database is shutdown in the
call to sqlplus. This shutdown terminates the sqlplus connection. When that happens in 12c, I get this to occur (as run from the command line):
SYS@ORCL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ORCL>exit
ERROR:
ORA-01012: not logged on
Process ID: 0
Session ID: 0 Serial number: 0
Compare this to a 11.2.0.3 database, when I shut it down:
SYS@DB03>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@DB03>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
The top one leads to a "non-zero" OS code for "last command executed".
The script uses calls to sqlplus like the following and always checks the return code:
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/dbhome_1
echo testing nothing with db shut down
$ORACLE_HOME/bin/sqlplus / as sysdba << EOF
whenever sqlerror exit sql.sqlcode
quit;
EOF
OS_ERROR_CODE=${PIPESTATUS[0]}
if [ "${OS_ERROR_CODE}" -ne "0" ]
then
echo "OS Error code bad : " ${OS_ERROR_CODE}
else
echo "OS Error code good "
fi
Every time I execute this in a 12c environment, a non-zero return code is found.
Is there something I did not configure in sqlplus?
I am not sure how to get this script to continue with the current lines of code.
Though, the original author must have got it to work, which seems to point to environment.
The operating system is Linux x86-64.
Any insight is appreciated.
Thanks,
John