26.3 A Wrapper Plugin for sqlplus

To query an Oracle database, sqlplus is given the appropriate SQL statement via standard input and receives a reply via the standard output:

user@linux:~$ echo "select trash from nothing" |\
 sqlplus -i wob/password@//192.168.1.9/DEMO
select trash from nothing
               *

ERROR at line 1:
ORA-00942: table or view does not exist

The switch -s (silent) prevents the output of things like version and copyright, and restricts the reply to the really interesting part. If the query fails, as above, the text merely points out the error that has occurred. sqlplus itself only returns an error status as a return value if the error occurred when using the client itself, otherwise it just returns OK (command executed). This is why sqlplus ...

Get Nagios, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.