欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

带参数存储过程写法

程序员文章站 2022-03-11 16:49:31
create or replace package body PKG_CheckVehicleInfo is– Author : XIE– Created : 2018/4/26 10:26:38– Purpose : 检测车辆信息– Pro_CheckOffLineDays :检测车辆离线天数procedure Pro_CheckOffLineDaysasv_vehicleID number; --车辆IDv_Finally_Online_Time date; --最后在...

create or replace package body PKG_CheckVehicleInfo is
– Author : XIE
– Created : 2018/4/26 10:26:38
– Purpose : 检测车辆信息
– Pro_CheckOffLineDays :检测车辆离线天数
procedure Pro_CheckOffLineDays
as
v_vehicleID number; --车辆ID
v_Finally_Online_Time date; --最后在线时间
v_VehicleNum varchar2(50); --车牌号码

cursor cur_part is select vehicleid,finally_time,vehiclenum from
(select distinct t.vehicleid,max(t.devtime) finally_time from Reallocate t group by t.vehicleid) r
join vehicle v on r.vehicleid=v.id ;
Begin

open cur_part;
loop
fetch cur_part into v_vehicleID,v_Finally_Online_Time,v_VehicleNum;
exit when cur_part%notfound;
if ROUND(TO_NUMBER(sysdate - v_Finally_Online_Time))>30 then

insert into ALARMMESSAGE (VEHICLEID,VEHICLENUM,ALARMTYPE,CONTENT,ALARMTIME,NOWARNING,URGENCYDEGREE)
values (v_vehicleID,v_VehicleNum,‘离线预警’,‘车辆离线天数异常’,SYSDATE,0,2);

else
null;
end if;
end loop;
close cur_part;
end Pro_CheckOffLineDays;
end PKG_CheckVehicleInfo;

本文地址:https://blog.csdn.net/xyx_0300/article/details/107667929

相关标签: Oracle