有没有办法在一个脚本中创建多个触发器? [英] Is there a way to create multiple triggers in one script?

查看:363
本文介绍了有没有办法在一个脚本中创建多个触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建多个触发器,只需要将一个脚本上传到Oracle DB / APEX工作区,并运行一次。

I am trying to create multiple triggers with only uploading one script into an Oracle DB / APEX workspace, and running it once.

我试图使用:

    create or replace trigger "BI_TEC_ROLES"   
      before insert on "TEC_ROLES"               
      for each row  
    begin   
      if :NEW."ROLE_ID" is null then 
        select "TEC_ROLES_SEQ".nextval into :NEW."ROLE_ID" from dual; 
      end if; 
    end; 

    create or replace trigger "BI_TEC_STATUSES"   
      before insert on "TEC_STATUSES"               
      for each row  
    begin   
      if :NEW."STATUS_ID" is null then 
        select "TEC_STATUSES_SEQ".nextval into :NEW."STATUS_ID" from dual; 
      end if; 
    end; 

    create or replace trigger "BI_TEC_SUBS"   
      before insert on "TEC_SUBS"               
      for each row  
    begin   
      if :NEW."SUB_ID" is null then 
        select "TEC_SUBS_SEQ".nextval into :NEW."SUB_ID" from dual; 
      end if; 
    end; 

我试过把GO放在每个块之间,但仍然只创建第一个触发器,第二个语句错误:

I have tried putting GO in between each individual block, but still only creates the first trigger then gives me an error for the second saying:

    Error(7,1): PLS-00103: Encountered the symbol "CREATE" 

我希望可以这样做。非常感谢您的时间和兴趣=)

I am hoping that it is possible to do this. Thank you very much for your time and interest =)

推荐答案

在每次触发后在新行上添加正斜杠,命令在缓冲区中:

Add a forward slash on a new line after each trigger to execute the command in the buffer:

create trigger...
...
end;
/

这篇关于有没有办法在一个脚本中创建多个触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆