日期:2014-05-17 浏览次数:20961 次
create or replace procedure p_ysgl_fkqk(as_year Varchar2) Is vn_bfje number(22,6); vs_ysnf Varchar2(4); vs_ysbh Varchar2(50); vn_htje number(22,6); cursor cur_ysgl_fkqk Is Select c_ysnf,c_ysbh,n_bfje_hz,n_htje --这一句不懂 From --v_ysgl_fkqk (select c_ysnf,c_ysbh,sum(nvl(n_bfje,0)) n_bfje_hz,max(nvl(n_ysje_tzsp,0)) n_htje from tab_bfspb a where a.c_ysnf=as_year group by c_ysnf,c_ysbh) Where c_ysnf=as_year Order By c_ysbh; --这里()里面的select语句我知道,把它当一个整体后from它是什么意思呢? Begin Update tab_ysgk Set n_ljbfje=null,n_ljye=null where c_ysnf = vs_ysnf; Commit; open cur_ysgl_fkqk; ----open 是什么意思啊,打开的是什么东西 loop fetch cur_ysgl_fkqk into vs_ysnf,vs_ysbh,vn_bfje,vn_htje; exit when cur_ysgl_fkqk%notfound; Update tab_ysgk Set n_ljbfje = vn_bfje,n_ljhtje = vn_htje Where c_ysbh = vs_ysbh And c_ysnf = vs_ysnf; commit; Update tab_ysgk Set n_ljye = nvl(n_ysje_tzsp,0) - nvl(vn_bfje,0), n_ljhtjeye = nvl(n_ljhtje,0) - nvl(vn_bfje,0) Where c_ysbh = vs_ysbh And c_ysnf = vs_ysnf; commit; end loop; --------这里loop是和上面的loop对应的吗,是不是表示循环,当exit 的条件满足是就跳出了循环 Close cur_ysgl_fkqk; Update tab_ysgk Set n_ljbfje = 0 Where n_isleaf = 1 And n_ljbfje Is Null; Update tab_ysgk Set n_ljye = nvl(n_ysje_tzsp,0) - nvl(n_ljbfje,0) Where n_isleaf = 1 And n_ljye Is Null; Update tab_ysgk Set n_ljhtje = n_ysje_tzsp Where n_isleaf = 1 And n_ljbfje = 0; Commit; end p_ysgl_fkqk; ----结束的时候语法是怎样的?(end 存储过程名字)????