zoukankan      html  css  js  c++  java
  • Oracle 存储过程的创建,及触发器调用存储过程

     

    一、创建存储过程

    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; --启用触发器 

    参考文章

    Oracle--存储过程

    Oracle 触发器调用存储过程

  • 相关阅读:
    Fire
    Apple Tree
    访问艺术馆
    三角关系
    字母表
    折纸
    旅行
    单词分类

    圆桌游戏
  • 原文地址:https://www.cnblogs.com/arxive/p/5959123.html
Copyright © 2011-2022 走看看