Oracle函数问题,报(ORA-01422: 实际返回的行数超出请求的行数
createorreplacefunctionget_doctor_groups(cnuminstaff_vs_group.EMP_NO%type)returnstaff...
create or replace function get_doctor_groups(cnum in staff_vs_group.EMP_NO%type)
return staff_vs_group.group_class%type as cclass staff_vs_group.group_class%type;
begin
select distinct group_class
into cclass
from staff_vs_group , staff_dict
where staff_vs_group.emp_no = staff_dict.emp_no and rownum=1;
---加上rownum=1就可以了,不加则报出01422的错误,为什么?
return (cclass);
end; 展开
return staff_vs_group.group_class%type as cclass staff_vs_group.group_class%type;
begin
select distinct group_class
into cclass
from staff_vs_group , staff_dict
where staff_vs_group.emp_no = staff_dict.emp_no and rownum=1;
---加上rownum=1就可以了,不加则报出01422的错误,为什么?
return (cclass);
end; 展开
3个回答
展开全部
select into 只能处理返回一行的情况,在返回多行与没有返回数据的时候都会报错。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ORA-01422: exact fetch returns more than requested number of rows
Cause: The number specified in exact fetch is less than the rows returned.
Action: Rewrite the query or change number of rows requested
Cause: The number specified in exact fetch is less than the rows returned.
Action: Rewrite the query or change number of rows requested
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询