一、创建存储过程
1、存储过程写法
create or replace procedure HVM_BYQ_TJ--变压器统计信息--->入库(id in number)asbeginfor num in 1..2 loopif num=1 thenupdate 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 thenupdate 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_BYQafter insert or update or delete on Xftpj_Pjjl_Byqdeclare
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; --启用触发器
参考文章
Oracle--存储过程
Oracle 触发器调用存储过程
如果觉得《Oracle 存储过程的创建 及触发器调用存储过程》对你有帮助,请点赞、收藏,并留下你的观点哦!