循环A表,根据查询结果,更新A表字段

create or replace procedure prc_user_xtzx_match(p_flag out varchar2) IS
xingming_match_loginname varchar(100);
sfzh_match_loginname varchar(100);
BEGIN
  FOR c_row IN (SELECT * FROM t_user_xtzx) LOOP
  --SELECT S.LOGIN_NAME INTO xingming_match_loginname T_USER S WHERE S.NAME=c_row.xingmin;
  dbms_output.put_line('开始处理'||c_row.ID);
  select case
         when count(t.LOGIN_NAME) = 0 then
          ''
         else
          max(t.LOGIN_NAME)
       end  INTO xingming_match_loginname
  from T_USER t
 where t.NAME = c_row.xingmin;
 UPDATE t_user_xtzx S SET S.XINGMIN_MATCH=xingming_match_loginname WHERE S.ID=c_row.ID;
  COMMIT;
  
  
  select case
         when count(t.LOGIN_NAME) = 0 then
          ''
         else
          max(t.LOGIN_NAME)
       end  INTO sfzh_match_loginname
  from T_USER t
 where t.sfzh = c_row.sfzh;
  UPDATE t_user_xtzx S SET S.Sfzh_Match=sfzh_match_loginname WHERE S.ID=c_row.ID;
  COMMIT;
 
 
  END LOOP;
  p_flag := '1';
END prc_user_xtzx_match;

 

posted @ 2018-09-29 11:22  伍叶春  阅读(200)  评论(0编辑  收藏  举报