Return Code is always Zero when Calling Unix Shell Commands from 10g Version of Sqlplus (Doc ID 552815.1)

Last updated on OCTOBER 28, 2016

Applies to:

SQL*Plus - Version 10.2.0.1 and later
Information in this document applies to any platform.
"Checked for relevance on 21-Mar-2013"


Symptoms

Host commands from sqlplus on version 10g always returns zero not trapping the error when logged into the database without connect string (userid/passwd). However, when logged into the database with connect string (userid/passwd@connect), host commands are able to trap any error and returns non-zero.

Steps to reproduce:
----------------------
1. export TBL1="abcde:fghij"
2. export TBL2="ABCDE"
3. Log into database without connect string (userid/passwd)
4. SQL> !print "$TBL1" | grep ":";echo $?
abcde:fghij
0
5. SQL> !print "$TBL2" | grep ":";echo $?
0 -> This is incorrect result, it should return 1
6. Logout and login again with connect string (userid/passwd@conn) and execute repeat steps 4 and 5 , it will return proper results.

Changes

Upgrade database from 9i or older to 10g.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms