title: How to (within code) Disconnect from SQL Connection on Incorrect Table Name?
body: <p><strong>Scenario</strong>:</p>
  
  <p>I have a batch script that calls a .sql file via sqlplus. The .sql file is as follows:</p>
  
  <pre><code>set serveroutput on
  variable out_val varchar2;
  exec &amp;1;
  print out_val
  exit
  </code></pre>
  
  <p><strong>Issue</strong>:</p>
  
  <p>The batch script passes a string on which the .sql executes. I expect that this string be correct 99% of the time, but I need to plan for that last 1% because the batch will be called once every 5 minutes. When the .sql is passed the correct login information and schema but the incorrect table name, my batch hangs and does not automatically close itself. Instead, it stays logged in to the sql connection until I hit Ctrl+C and manually close it. I tried the following TRY/CATCH block but it didn't change the issue:</p>
  
  <pre><code>set serveroutput on
  variable out_val varchar2;
  begin try
  exec &amp;1;
  end try
  begin catch
  exit
  end catch
  print out_val
  exit
  </code></pre>
  
  <p><strong>Question</strong>:</p>
  
  <p>How do I code either a batch script or a sql code block to automatically disconnect from a sql connection if the inputted table name is incorrect? (Note that I can't use IF statements to test every possible table name, there are too many and they may change often. It needs to be able to disconnect if the table name cannot be found.)</p>