sql%rowcount 为零??

本文记录了一个关于用户登录日志同步的问题排查过程。主要探讨了在从源系统同步用户登录记录到目标系统的SQL过程中遇到的数据缺失问题,并详细分析了可能的原因及解决思路。

begin
 starttime:=sysdate;
 v_maxtime := to_date('9999-12-31 00:00:00','yyyy-mm-dd hh24:mi:ss');  
 select max(f_logintime) into v_maxtime from t_gather_userloginlog;
 
  if  v_maxtime != to_date('9999-12-31 00:00:00','yyyy-mm-dd hh24:mi:ss') then
  
    insert  into t_gather_userloginlog (f_userid,f_username,f_logintime,f_userip,f_loginflag,f_logintype) --来源主网登陆的。
      select  f_uid,f_username,f_logintime,f_ip,f_flag,f_type from t_webloginlog_bak@link_stdby w where w.f_logintime > v_maxtime;
    
    insert into t_gather_userloginlog (f_userid,f_username,f_logintime,f_userip) --来源其他地方登陆。
     select ui_id,ui_username,ui_lasttime,ui_lastip
     from b_expuserinfo@link_stdby inner join t_webloginlog_bak@link_stdby
     on ui_username = f_username and ui_lastip = f_ip and f_logintime=ui_lasttime and f_logintime > v_maxtime
     where   f_username is null and ui_lasttime > v_maxtime;
   
     
  end if;
 
  rownumber := sql%rowcount;
  insert into t_base_sp_runlog values('gather','p_Gather_Day_i_UserLoginLog02',sysdate,'成功','INSERT', rownumber,round((dbms_utility.get_time-l_start)/100,2),starttime);
  commit;  

 

 

跑了很多天日志记录该过程影响行数为0! 不可能没有用户登陆啊

 

经过一番查证后:

    insert  into t_gather_userloginlog (f_userid,f_username,f_logintime,f_userip,f_loginflag,f_logintype) --来源主网登陆的。
      select  f_uid,f_username,f_logintime,f_ip,f_flag,f_type from t_webloginlog_bak@link_stdby w where w.f_logintime > v_maxtime;
  rownumber := sql%rowcount;--这里有数据
    


    insert into t_gather_userloginlog (f_userid,f_username,f_logintime,f_userip) --来源其他地方登陆。
     select ui_id,ui_username,ui_lasttime,ui_lastip
     from b_expuserinfo@link_stdby inner join t_webloginlog_bak@link_stdby
     on ui_username = f_username and ui_lastip = f_ip and f_logintime=ui_lasttime and f_logintime > v_maxtime
     where   f_username is null and ui_lasttime > v_maxtime;
      rownumber := sql%rowcount; --在这里变量被清空了
      
  end if;
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值