3 Replies Latest reply on Feb 25, 2015 3:00 AM by Cuauhtemoc Amox

    command line 'host ls -l /tmp/nosuchfile' triggers neither OSError nor SQLError exceptions and _RC (et al?) usage examples are not clear


      SQL Developer Build MAIN-16.84

      Fedora 21


      In a scripting language like bash I am able to test for and show a file does not exist by:


      ls -l /tmp/nosuchfile


      if [ $status -ne 0  ] ; then

           echo File does not exist

           exit $status



      However, in SQL Developer when I try:


      whenever OSerror exit failure rollback

      whenever sqlerror exit failure rollback

      host ls -l /tmp/nosuchfile

      exit success


      What is shown in the Script Output window is:


      ERROR: There was output on STDERR

      ls: cannot access /tmp/nosuchfile: No such file or directory



      I believe because 'Commit' is shown the exception handlers were not invoked (not that I really expected sqlerror to be...).



      • /tmp/nosuchfile does not exist as expected and shown by the output of ls.
      • yes, there are better ways to write the bash script fragment (variations off of the test(1) command).  This one matches my attempted SQLPlus commands the best.
      • I have seen references to using _RC (and other) variables but (being relatively new to SQL*PLUS and PL/SQL) I have not been able to get the variable defined and set with the exit status from the ls (1) [and hopefully SQLPLUS host] command so it could possibly be used in a subsequent PL/SQL BEGIN/END block.



      • Was it reasonable to expect OSerror to be raised by an error status returned to the host command?
      • How does on declare and reference the external command status variable (_RC ??) to get the status back from the host command?