一、创建存储过程
1、存储过程写法
create or replace procedure HVM_BYQ_TJ --变压器统计信息--->入库
(id in number)
as
begin
for num in 1..2 loop
if num=1 then
update hvm_zsb_tj set byq=(select count(0) as hangshu from hvm_view_ObjectZTPJ_Byq t where t.StsRes = '正常状态' and t.bdzdydj = '500kV') where id=1;
end if;
if num=2 then
update hvm_zsb_tj set byq=(select count(0) as hangshu from hvm_view_ObjectZTPJ_Byq t where t.StsRes = '注意状态' and t.bdzdydj = '500kV') where id=2;
end if;
end loop; end HVM_BYQ_TJ;
2、调用
call HVM_BYQ_TJ(1);
二、触发器调用存储过程
1、创建触发器
create or replace trigger HVM_ZTPJ_BYQ
after insert or update or delete on Xftpj_Pjjl_Byq
declare
begin
--直接写存储过程名称+;
hvm_byq_tj(1);
end HVM_ZTPJ_BYQ;
2、触发器的启用与禁用
alter table xftpj_pjjl_byq disable all triggers; --禁用触发器
alter table xftpj_pjjl_byq enable all triggers; --启用触发器
参考文章