oracle 存儲過程 實例 循環 給查詢賦值 遊標取值

CREATE OR REPLACE PROCEDURE p_updete_gs is     --僅供參考
  i_jdid varchar(32);
  i_ryid varchar(32);

  cursor cur is --遊標  給查詢賦值
  select c.jdid jdid, t.ryid rybh from t_zcj_rctj t,t_zj_jd c where
  t.ryid=c.rybh and t.bgzt<>'3' and c.bgzt<>'3'and c.zjjd<>3 
  and c.sfsp='3' and sysdate-sspsj2>='5';
BEGIN
    for x in cur loop--遊標取值 循環
      i_jdid :=x.jdid;
      i_ryid:=x.rybh;
    --自己的語句
      update xxx set xx='3' where  x=i_jdid;
      update xxxx set xxxxx='3' where xx=i_ryid;
    end loop;

--這可以給記錄表插數據
end ;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章