title: Oracle APEX item validation (Function returning boolean) ORA-01403
body: <p>I am trying to validate a field in APEX.</p>
  
  <p><strong>What it is supposed to do:</strong><br />
  Check if applicant is under aged (age &lt; 18), if true, a legal representative is required.<br />
  This will be checked with the persons BSN.</p>
  
  <p><strong>Fields:</strong><br />
  P68_REKENINGHOUDER (Contains BSN of applicant).<br />
  P68_WETV1 (Contains BSN of legal representative).</p>
  
  <p><strong>Function:</strong><br />
  GetLeeftijd: (Gets the persons age, tested and works)</p>
  
  <pre><code>create or replace Function GetLeeftijd(bsn_nummer number)
  RETURN NUMBER
  AS
  v_leeftijd NUMBER := 18;
  
  BEGIN
    SELECT months_between(SYSDATE, CAST("PERSONEN"."GEBOORTEDATUM" AS DATE)) /12 INTO v_leeftijd
    FROM dual, "PERSONEN"
    WHERE "PERSONEN"."BSN" = bsn_nummer;
  
  RETURN v_leeftijd;
  
  END;
  </code></pre>
  
  <p><strong>Item validation (Type: Function Returning Boolean ON Create)</strong></p>
  
  <pre><code>declare
  
  v_rekh number;
  v_wetv number;
  
  begin
  v_rekh := GetLeeftijd(:P68_REKENINGHOUDER);
  v_wetv := GetLeeftijd(:P68_WETV1);
  
    if v_rekh &lt; 18 then
      if :P68_WETV1 is NULL then
        return false;
      else
        if v_wetv &lt; 18 then
          return false;
        else
          return true;
        end if;
      end if;
    else
      return true;
    end if;
  end;
  </code></pre>
  
  <p><strong>What actually happens:</strong><br />
  Getting a no data found error.</p>
  
  <pre><code>ORA-01403: Geen gegevens gevonden.
  Error   ERR-1021 Unable to run "function body returning boolean" validation. 
  </code></pre>
  
  <p><strong>Other info:</strong><br />
  Running Application Express 4.0.0.00.46<br />
  The function above is not polished yet but it works for now.</p>