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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.