我正在尝试创建一个返回多行的函数。
以下是我的功能和类型
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.first_name,
emp_record.last_name,emp_record.depart_name
from employees a, departments b
where a.department_id=b.department_id and location_id=loc;
return(emp_record);
end;
Run Code Online (Sandbox Code Playgroud)
我用过
select get_employee(5) from dual;
Run Code Online (Sandbox Code Playgroud)
我收到“ exact fetch returns more than requested number of rows”错误。后来当我rownum<2在选择查询中使用时,我得到了“ Reference to uninitialized composite”。
能否请你帮忙?
提前致谢