in reply to Here document and sqlplus

try this:
print SQLPLUS <<SQL spool anyfile.log; select * from tab where tnam like 'monks'; spool off SQL close SQLPLUS;

You can then analyse the content of the spool file either manually or within your program.
You should also check the return value of sqlplus ...
Imre