create or replace procedure SP_MI_Monitor(
I_PointGroup nvarchar2,
I_Value number,
I_ErrorCode nvarchar2,
I_active number
)
as
v_count INTEGER :=0;
begin
--是否数据已存在
select count(*) into v_count from MI_Monitor where PointGroup = I_PointGroup;
if v_count = 0 then
--若没有数据,则执行插入操作
insert into MI_Monitor(PointGroup,Val,ErrorCode,active)
values(I_PointGroup,I_Value,I_ErrorCode,I_active);
commit; -- if you are in standard opseration ,commit should not be forgotten
else
--否则,执行更新操作
update MI_Monitor
set
Val=I_Value,
ErrorCode=I_ErrorCode,
active=I_active
where
PointGroup=I_PointGroup;
commit;
end if;
end;