title: Oracle PL/SQL - Are NO_DATA_FOUND Exceptions bad for stored procedure performance?
body: <p>I'm writing a stored procedure that needs to have a lot of conditioning in it.  With the general knowledge from C#.NET coding that exceptions can hurt performance, I've always avoided using them in PL/SQL as well.  My conditioning in this stored proc mostly revolves around whether or not a record exists, which I could do one of two ways:</p>
  
  <pre><code>SELECT COUNT(*) INTO var WHERE condition;
  IF var &gt; 0 THEN
     SELECT NEEDED_FIELD INTO otherVar WHERE condition;
  ....
  </code></pre>
  
  <p><b>-or-</b></p>
  
  <pre><code>SELECT NEEDED_FIELD INTO var WHERE condition;
  EXCEPTION
  WHEN NO_DATA_FOUND
  ....
  </code></pre>
  
  <p>The second case seems a bit more elegant to me, because then I can use NEEDED_FIELD, which I would have had to select in the first statement after the condition in the first case.  Less code.  But if the stored procedure will run faster using the COUNT(*), then I don't mind typing a little more to make up processing speed.</p>
  
  <p>Any hints?  Am I missing another possibility?</p>
  
  <p><b>EDIT</b>
  I should have mentioned that this is all already nested in a FOR LOOP.  Not sure if this makes a difference with using a cursor, since I don't think I can DECLARE the cursor as a select in the FOR LOOP.</p>