title: Function returned without value
body: <p>This is the function which I designed. It got complied successfully</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION "F_CHECK"
  (
      p_id IN VARCHAR2
      p_name IN VARCHAR2)RETURN VARCHAR2
      is 
      v_id VARCHAR2;
      v_name VARCHAR2;
      cnt pls_integer;
      BEGIN
          IF id IS NULL THEN
              RETURN NULL;
          END IF;
          SELECT COUNT(*) INTO cnt from emp_new where id = p_id;
          IF (cnt &gt; 0) THEN
              SELECT id, name INTO v_id, v_name from emp_new where id=p_id;
          IF (v_id is null and p_id is null and v_name is null and p_name is null) THEN
              return NULL;    
          ELSE
              IF (v_name =trunc(p_name)) then
                  return NULL;
              else
                  insert into employees values(p_id,p_name,sysdate);
              end if;
          end if;
       end if;
  
      exception
      when DUP_VAL_ON_INDEX THEN
      raise application error (-20001, 'NAME EXISTS UNDER DIFFERENT ID');
      END F_CHECK;
  </code></pre>
  
  <p>But I'm not getting the expected result, when I execute the function</p>
  
  <pre><code>select F_CHECK(1,1) from dual;
  </code></pre>
  
  <p>ERROR I'M getting is:</p>
  
  <pre><code>SQL EEROR: ORA-06503: PL/SQL : FUNCTION RETURNED WITHOUT VALUE
  </code></pre>