oracle 循环遍历

Declare
  CURSOR bcur IS  SELECT USER_DEPT_ID FROM t_uums_upg_user_dept_sysrole;
 
  brec bcur%ROWTYPE;
BEGIN
  OPEN bcur;
  LOOP
    FETCH bcur
      INTO brec;
    EXIT WHEN bcur%NOTFOUND;
     update  t_uums_upg_user_dept_sysrole_t@UUMS_TO_ESB_91 set USER_DEPT_STATUS='N',USER_DEPT_EXPLAIN='重复' where USER_DEPT_ID=brec.USER_DEPT_ID;
  END LOOP;
  CLOSE bcur;
END;
/

------------------------------------------------------------------------------------------------------------


create or replace procedure SP_UUMS_DEPT_ROLE_TEST
is
cursor cursorUser is  SELECT USER_DEPT_ID FROM t_uums_upg_user_dept_sysrole_t@UUMS_TO_ESB_91;




  begin
  for userRoleTEMP in cursorUser loop
    begin
   update  t_uums_upg_user_dept_sysrole_t@UUMS_TO_ESB_91 set USER_DEPT_STATUS='N',USER_DEPT_EXPLAIN='重复' where USER_DEPT_ID=userRoleTEMP.USER_DEPT_ID;
    end;
  end loop;
  commit;
end;

你可能感兴趣的:(SQL,DB)