title: Function having an in parameter and returning a object type
body: <p><strong>How can I pass number as in parameter and return a object type in a function</strong></p>
  
  <pre><code>create type my_details as 
  object(v_ename varchar2(20),v_sal number(10));
  
  
  create or replace function f_emp(v_empno in number)
    return my_details
  as
    v_det my_details;
  begin
    select ename,sal 
      into v_det.v_ename,v_det.v_sal 
      from emp 
     where empno=v_empno;
    return v_det;
   end;
  </code></pre>
  
  <p>When I try to call the function, I get an error</p>
  
  <pre><code>declare
    v_type my_details;
  begin
    v_type:=f_emp(7839);
  end;
  /
  </code></pre>
  
  <p>The error stack</p>
  
  <pre><code>declare
  *
  ERROR at line 1:
  ORA-06530: Reference to uninitialized composite
  ORA-06512: at "SCOTT.F_EMP", line 6
  ORA-06512: at line 4
  </code></pre>
  
  <p>Can any one help me pointing out where I have made mistake and how can I improve this?</p>