小弟新手,写了个存储过程,但总有错,请大家帮忙改下,
万分感谢!!!   
     
     (postid in number,somid in char(14),
      balancemoney out number)
as
  somid_c number;
  counter number;
begin
select childcount into conuter from system.hr_gatheringbill where somid=somid;
if (counter>0) then
  select balancemoney from system.hr_gatheringregion
    where postid in
      ( select max(postid)
        from system.hr_gatheringregion
      );                             ---输出balancemoney值
else (counter=0)
  begin
     select count(somid) into somid_c from system.hr_gatheringregion 
     where somid=somid;
    if (somid_c=1) then
     select balancemoney from system.hr_gatheringregion
     where primaryid=(select somid from system.hr_gatheringbill
                      where createtime in
                            ( select max(createtime) 
                              from system.hr_gatheringbill
                             )
                     );               ---输出balancemoney值
    
    else (somid_c=0)         
          balancemoney=0;             ---输出balancemoney=0
    end if;
  end;
end if;
end;

解决方案 »

  1.   

    select childcount into conuter from system.hr_gatheringbill where somid=somid;
    变量名称不要跟字段名称冲突!
      

  2.   

    报错信息是什么~?看不出什么来,
    else (counter=0)换成elsif(counter=0)试试
      

  3.   

    select childcount into conuter from system.hr_gatheringbill where somid=somid;变量名称不要跟字段名称冲突一般起v_childcount为变量名称
      

  4.   

    select childcount into conuter from system.hr_gatheringbill where somid=somid
    ------------------
    这是永真式  应该查出多条记录,这时select into 会抛异常