Is there a way to create multiple triggers in one script?

后端 未结 5 1569
误落风尘
误落风尘 2020-12-17 09:00

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

Here is a brief script compared to th

5条回答
  •  春和景丽
    2020-12-17 09:37

    Yes we can execute multiple procedure/trigger/function in single script using the FORWARD SLASH / inside the sql file.

    Like below:

    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; 
    
    /
    

    Then oracle will consider it as new statement/block.

提交回复
热议问题