Re: SQLPLUS Question

From: Hans Henrik Krohn <>
Date: Mon, 25 Jan 2010 07:44:55 -0800 (PST)
Message-ID: <>

On 22 Jan., 00:24, Noons <> wrote:
> On Jan 22, 8:25 am, Jeremy <> wrote:
> > Many thanks, the best and most relevant response to this thread. Though
> > to be fair, I'm glad we all know how to spell each other's names now.
> LOL!  Indeed!
> Just a small warning re some of these more "advanced" uses of sqlplus:
> it wouldn't be the first time features suddently change or stop
> working from release to release.
> I am reminded of the very first 7 release, when sqlplus introduced
> return codes so we could trap errors from the shell: it worked, sort
> of. Took two patch release levels before it was stable enough to be
> used, then it broke again in first release of 8!
> I recall standing in front of a Sun workstation showing the problem to
> Ken Jacobs and watching his jaw drop at how shaky the whole thing was.
> He must have kicked some ass because the problem didn't show up
> again.  But the yellow light remained.
> So, if using anything that is not mainstream or considered more
> advanced, do yourself a favour and:
> test early,
> test often,
> test repeatedly.

De-lurking here for a minute: In 10g and upwards on some *nix platforms (AIX, HP, Solaris), you need to have bequeath_detach=true in your sqlnet.ora if you connect to the database locally using sql*plus (e.g. if you don't connect via sql*Net), and you want correct returncodes  from hosted commands.
Otherwise you'll see every command in a shell started from sql*plus having return-code 0, like this:

xxxxxx:/home/hhk> sqlplus /
. . . banner-info . . .
SQL hhk_at_ora10gR2> host
xxxxxx:/home/hhk>ls -l doesnt.exist
ls: 0653-341 The file doesnt.exist does not exist. xxxxxx:/home/hhk>echo $?

This is better explained in a note on MOS (formerly MetaLink), document [ID 552815.1] "Return Code is always Zero when Calling Unix Shell Commands from 10g Version of Sqlplus".

Best regards,
Hans Henrik Krohn Received on Mon Jan 25 2010 - 09:44:55 CST

Original text of this message