I'm trying to return a multiple values in a %rowtype from a function using two table(employees and departments), but it not working for me.
create or replace function get_employee
 (loc in number)
return mv_emp%rowtype
as  
   emp_record mv_emp%rowtype;
begin
   select a.first_name, a.last_name, b.department_name into emp_record 
   from employees a, departments b 
   where a.department_id=b.department_id and location_id=loc;
   return(emp_record);  
end;
                The above function compiled without any error? What is the type of MV_EMP? Ideally, it should be something like below.
create or replace type emp_type
(
first_name varchar2(20)
, last_name varchar2(20)
, depart_name varchar2(20)
)
/
create or replace function get_employee
 (loc in number)
return emp_type
as  
   emp_record emp_type;
begin
   select a.first_name, a.last_name, b.department_name into emp_record 
   from employees a, departments b 
   where a.department_id=b.department_id and location_id=loc;
   return(emp_record);  
end;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With