此存储过程实现功能:
监控服务统计表,并自动累加总成功、失败和请求次数,以及计算全局健康度。
create or replace procedure "FXKH_SERVICEMONITOR" (path in varchar2,newstatus in number, newsuc_count in number, newerr_count in number, newmsg_count in number) is
sid number; --服务管理表中不存在的服务id
sid2 number; --服务id
allsuc_count number; --所有成功次数
allmsg_count number; --所有请求次数
all_health number; --全局健康度
all_rate number;--全局正确率
cursor notin_cur is --声明服务状态表中不存在于服务管理表的服务的游标
select serviceid from P_WS_SERVICE_STATUS where serviceid not in (select serviceid from P_WS_SERVICEMANAGEMENT);
cursor sid_cur is --声明服务管理表中匹配到服务名的游标
select o.serviceid from P_WS_SERVICEMANAGEMENT o where (o.publishpath like path) and rownum<=1;
begin -- main
--循环开始
for n in notin_cur loop
sid := n.serviceid;
--将不存在于服务管理表的服务的status置为健康度最低级:0
update P_WS_SERVICE_STATUS set status=0 where serviceid = sid;
end loop;
--循环结束
--循环开始
for s in sid_cur loop
sid2 := s.serviceid;
--通过服务管理表中匹配到服务名的服务id在服务状态表中查询所有成功次数和所有请求次数
select allsuccesscount,allmessagecount into allsuc_count,allmsg_count
from P_WS_SERVICE_STATUS where serviceid = sid2;
if allsuc_count=allmsg_count then
all_rate := 100;
end if;
if allsuc_count!=allmsg_count then
all_rate := (allsuc_count+newsuc_count)/(allmsg_count+newmsg_count)*100;
end if;
--获取相应全局健康度开始
if all_rate>=0 and all_rate<=30 then
all_health := 0;
end if;
if all_rate>30 and all_rate<=60 then
all_health := 1;
end if;
if all_rate>60 and all_rate<=70 then
all_health := 2;
end if;
if all_rate>70 and all_rate<=80 then
all_health := 3;
end if;
if all_rate>80 and all_rate<=90 then
all_health := 4;
end if;
if all_rate>90 and all_rate<=100 then
all_health := 5;
end if;
--获取相应全局健康度结束
--通过服务id更新服务状态表中的所有成功次数,所有失败次数和所有请求次数
update P_WS_SERVICE_STATUS set status=newstatus,updatetime=sysdate,allsuccesscount=allsuccesscount+newsuc_count,allerrorcount=allerrorcount+newerr_count,
allmessagecount=allmessagecount+newmsg_count,globalstatus=all_health where serviceid = sid2;
end loop;
--循环结束
end;
分享到:
相关推荐
本文实例讲述了Python使用cx_Oracle调用Oracle存储过程的方法。分享给大家供大家参考,具体如下: 这里主要测试在Python中通过cx_Oracle调用PL/SQL。 首先,在数据库端创建简单的存储过程。 create or replace ...
oracle 存储过程实例 oracle存储过程实例
oracle 存储过程导出excel oracle 存储过程导出excel oracle 存储过程导出excel oracle 存储过程导出excel oracle 存储过程导出excel
oracle 存储过程 unwrap 图形解密 工具
ibatis调用oracle存储过程分页
可以将SQL Server存储过程转为oracle存储过程的工具
帆软报表调用Oracle存储过程如果存储过程定义中没有参数,但是设计器中缺弹出一个storeParameter1参数的解决插件
oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记oracle存储过程笔记
oracle 存储过程批量提交
使用java实现oracle存储过程。 共有3个小例子。实现的功能 1、无返回值的存储过程 如 insert 2、有返回值的存储过程(非列表)select id from tab 3、返回列表 如:select * from tab 顺便鄙视下csdn,作为一个it...
oracle存储过程学习经典入门 非常好的 初学者必看
oracle 存储过程的基本语法 1.基本结构 CREATE OR REPLACE PROCEDURE 存储过程名字 ( 参数1 IN NUMBER, 参数2 IN NUMBER ) IS 变量1 INTEGER :=0; 变量2 DATE; BEGIN END 存储过程名字 2.SELECT INTO ...
oracle 存储过程 函数 dblink 绝对对工作和平时学习有价值的资料。针对个人具体情况做修改即可使用
Oracle存储过程中使用临时表 会话级临时表 事务级临时表
oracle 存储过程实例 oracle 存储过程实例 oracle 存储过程实例 oracle 存储过程实例
行业内Oracle存储过程最基本的开法规范,适合oracle入门小白学习
4、开发指南:《Oracle存储过程入门指南&100+种真实业务场景存储过程实例.pdf》,可以帮助初学者系统学习。 5、资源包括“通用存储过程整理” 和 “真实业务存储过程整理” 两部分,通用适合各种系统,可以无缝隙...
Oracle存储过程分页代码 Oracle存储过程分页代码 Oracle存储过程分页代码 Oracle存储过程分页代码 Oracle存储过程分页代码
linux系统中使用shell脚本对oracle存储过程进行编译
Oracle存储过程调用bat批处理脚本程序,ORACLE调用OS【调用BAT脚本等】