幾個ORACLE個觸發器!

來源:互聯網
上載者:User

create or replace trigger tri_SERVICE_TYPE
before Delete on SMS_SERVICE_TYPE
for each row
Declare

   Cant_Delete Exception;
Begin
   If Deleting Then
      --不允許刪除
      Raise Cant_Delete;
   End If;
   Exception
   When Cant_Delete Then
      Raise_Application_Error(-20007, '不允許刪除操作'); --Raise_Application_Error的用法在07-11-29日誌中有介紹。
End;

/

create or replace trigger tri_message302
before Insert on sms_message302
for each row
Declare
v_num1 number(10);
v_num2 number(10);
Begin
If Inserting Then
   v_num1 :=instr(:New.Content,':',1,1);
   v_num2 :=instr(:New.Content,':',1,1);
   If v_num1 > 0 Then

    :New.Content := replace(:New.Content,substr(:New.Content,1,v_num1-1),'影視報道');
   Elsif v_num1 = 0 And v_num2 > 0 Then
    :New.Content := replace(:New.Content,substr(:New.Content,1,v_num2-1),'影視報道');
   End If;

End If;

Exception
When Others Then
   Null;
End tri_message302;
/

create or replace trigger TRI_MISCRULE12
before insert or update on SMS_MISC_RULE_1_2
for each row
declare
SEQNO NUMBER(6);
begin

IF Upper(:new.MISCORDER) IN ('OTHERS','NULL') then
    :new.MISCORDER:=Upper(:new.MISCORDER);
    :new.ORDERlen:=0;
ELSE
    :new.MISCORDER:=Upper(:new.MISCORDER);
    :new.ORDERlen:=length(:new.MISCORDER);
END IF;
IF upper(:new.SMSCODE)='NORMAL' then
    :new.SMSCODE:='NORMAL';
:new.SMSMODE:=0;
:new.SMSLEN:=0;
ELSE
   :new.SMSLEN:=Length(:new.SMSCODE);
END IF;
   If Nvl(To_Char(:New.Ruleid), 'NULL') = 'NULL' Then
       SELECT SMS_MISC_RULESEQ.NEXTVAL INTO SEQNO FROM DUAL;
       :new.RULEID:=SEQNO;
   End If;

end TRI_MISCRULE12;
/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.