My Oracle Support Banner

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

Last updated on FEBRUARY 03, 2022

Applies to:

SQL*Plus - Version 10.2.0.1 and later
Information in this document applies to any platform.

Symptoms

Host commands from sqlplus on version 10g always returns zero not trapping the error when logged into the database without connect string (<USER>/<PASSWORD>). However, when logged into the database with connect string (<USER>/>PASSWORD>@<CONNECT_STRING>), 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 (<USER>/<PASSWORD>)
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 (<USER>/>PASSWORD>@<CONNECT_STRING>) and execute repeat steps 4 and 5 , it will return proper results.

Changes

Upgrade database from 9i or older to 10g.

Cause

To view full details, sign in with your My Oracle Support account.

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


In this Document
Symptoms
Changes
Cause
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.