title: IF NOT EXISTS In Function PLSQL
body: <p>I have a function which has three If/Then statements before opening a cursor. The If/Then statements check validity prior to opening the cursor.</p>
  
  <p>I would like to add one more If/Then validity check, however, it is a bit more complicated than the others. Below is a sample, and I have block commented what I would like to add:</p>
  
  <pre><code>begin
      if not procedure.validation_function (&lt;variable&gt;, &lt;condition&gt;=TRUE) then
          return variable2;
      end if;
  
     /* if not exists
      (
         SELECT 'x' FROM table1
         WHERE table1_id = variable1_id
         AND trunc(sysdate) &lt; trunc(table1_date + 60)
      ) then
          return variable2;
      end if; */
  
      open cursor(&lt;argument&gt;);
      fetch cursor into &lt;variable&gt;;
      close cursor;
      return &lt;variable&gt;;
  
  
  end;
  </code></pre>
  
  <p>My problem is that I come from a T-SQL world, and I am finding in PL/SQL the <em>if not exists</em> command does not work. Is there a way  I can, from within the function, have an If NO_DATA_FOUND statement where I utilize SELECT? </p>
  
  <p>Is there a way to nest another function within that, so I can:</p>
  
  <pre><code>begin
       SELECT ....
       FROM ....
       WHERE ....
          if NO_DATA_FOUND then
             return variable2;
          end if;
  end;
  </code></pre>