v_deviceid varchar2(20); --设备号 -- v_mobilephone varchar2(21); -- cursor c_1 is select tp.totalsteps,tp.faststeps,tp.slowsteps,tp.distance,tp.calorie from T_PEDOMETER tp where tp.userid = :new.userid and tp.receivetime = to_date(''||sysdate||'','yyyy-mm-dd'); -- r c_1%rowtype; BEGIN v_stride := 35; -- 可能发生异常 begin select tum.imsi into v_deviceid from T_USER_MSISDN tum where tum.userid = :new.userid; EXCEPTION WHEN NO_DATA_FOUND THEN null; end; if(v_deviceid is not null) then -- 查询用户的手机号 --select tub.mobilephone into v_mobilephone from T_USER_BASE tub where tub.userid = :new.userid; -- 今日完成步数 --select sum(tp.totalsteps) into v_totalsteps,sum(tp.faststeps) into v_faststeps,sum(tp.slowsteps) into v_slowsteps,sum(tp.distance) into v_distance,sum(tp.calorie) into v_calorie from T_PEDOMETER tp where tp.userid = :new.userid and tp.receivetime = to_date(''||sysdate||'','yyyy-mm-dd'); select steps,faststeps,slowsteps, distance, calorie
into v_totalsteps , v_faststeps , v_slowsteps, v_distance, v_calorie from (select sum(tp.totalsteps) as steps, sum(tp.faststeps) as faststeps, sum(tp.slowsteps) as slowsteps, sum(tp.distance) as distance, sum(tp.calorie) as calorie from T_PEDOMETER tp where tp.userid = :new.userid and tp.receivetime = to_date('' || sysdate || '', 'yyyy-mm-dd'));
insert into T_PEDOMETER_STAT(userid,Msisdn,TODAYACTUALSTEPS,TODAYFASTSTEPS,TODAYSLOWSTEPS,TODAYDISTANCE,TODAYCALARIE,TODAYDATE,BATTERY,STRIDE) values(:new.userid,''||v_deviceid||'',v_totalsteps,v_faststeps,v_slowsteps,v_distance,v_calorie,to_date(''||sysdate||'','yyyy-mm-dd'),20,v_stride); --insert into T_PEDOMETER_STAT values(v_userid,v_totalsteps,v_faststeps,v_slowsteps,:new.hour,v_calorie,v_distance,sysdate,to_date(''||:new.today||'','yyyy-mm-dd'),20,v_stride); end if;
select steps, faststeps, slowsteps, distance, calorie into v_totalsteps, v_faststeps, v_slowsteps, v_distance, v_calorie from (select sum(tp.totalsteps) as steps, sum(tp.faststeps) as faststeps, sum(tp.slowsteps) as slowsteps, sum(tp.distance) as distance, sum(tp.calorie) as calorie from T_PEDOMETER tp where tp.userid = :new.userid and tp.receivetime = to_date('' || sysdate || '', 'yyyy-mm-dd'));最后这个条件能取到数据吗?是不是应该在一个范围内!