1

我是plsql的新手。

我收到错误

ORA-01422: exact fetch returns more than requested number of rows  

问题是有时我需要从具有重复行的游标中进行选择
为了避免这种情况,我尝试添加
rownum=1 或 rownum<2

但这并没有解决问题

select work into my_work  
from INFO 
where person_id = in_person_id
and date= (select max(date) from INFO where (person_id = in_person_id and rownum<2     
));     

PS 原bug产生重复行无法修复

4

1 回答 1

3

rownum <2应用于子查询,而不是主查询。它应该是

select work into my_work  
from INFO 
where person_id = in_person_id
and date= (select max(date) from INFO where (person_id = in_person_id 
--and rownum<2  
)) 
AND rownum<2  ;     
于 2012-12-20T16:13:17.907 回答