oracle游标

基础模板

declare
bianliang date;
up_user varchar2(40);
cursor temp is
  select a.serial_match,a.item_code,b.serial_icd from bs_catalog_match a, bs_disease b where a.item_code = b.icd;
begin
  for i in temp loop
       select sysdate into bianliang from dual;--查询结果赋值给变量
    up_user:='admin';--变量赋值
      update bs_catalog_match set item_code = i.serial_icd,update_date=bianliang,update_user=up_user where serial_match = i.serial_match;
  end loop;
end; 

 

其中循环的方式有如下3种

1、

FOR M IN ( select key_original BOX_KEY from li93_regiebox_ref t WHERE t.ADMINCODE = V_ADMINCODE AND T.KEY_UNION = V_UNION_KEY)
   LOOP
      UPDATE LI93_REGIEBOX_REF T SET T.KEY_UNION=M.BOX_KEY
                    WHERE T.KEY_ORIGINAL = M.BOX_KEY;

END LOOP;

2、

while(1>0) loop

end loop;

3、

cursor cur is select sysdate from dual;

for s in cur loop

end loop;

你可能感兴趣的:(oracle)