update PRO_PLANT_SUMMARY_ALL a set  M_L_NORMAL_NET=
(select M_JZJ171 from  PRO_PLANT_ALL_ITEM b 
where b.TAB_YEAR=2013+-1 
and TAB_MONTH = 1+0 
and ((a.id=b.id)  
or( a.parent_id = b.parent_id  
and b.sub_dept_code is not null  
and b.sub_dept_code = (
select c.sub_dept_code from PRO_PLANT_ALL_ITEM c 
where c.tab_year = a.tab_year 
and c.tab_month = a.tab_month 
and c.id = a.id)
)
)

where a.TAB_YEAR=2013 and a.TAB_MONTH=1执行报错信息: ora-01427 single-row subquery returns more than one row
跪求排查语句

解决方案 »

  1.   

    tryselect c.sub_dept_code 
    =>
    select top 1 c.sub_dept_code 
      

  2.   

    典型的 TOO_MANY_ROWS 异常. google it
      

  3.   

    select c.sub_dept_code from PRO_PLANT_ALL_ITEM c 
    where c.tab_year = a.tab_year 
    and c.tab_month = a.tab_month 
    and c.id = a.id
    你执行下,看看返回值是几个?
    因为你用了‘b.sub_dept_code=’,如果上面的查询结果返回的行数大于一,就是问题的原因。
    解决方法就是把‘=’换为‘—’就行了。