Oracle: Return multiple values in a function

前端 未结 3 967
长情又很酷
长情又很酷 2021-02-10 17:06

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 fu         


        
3条回答
  •  离开以前
    2021-02-10 18:05

    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;
    

提交回复
热议问题