A few Oracle triggers!

Source: Internet
Author: 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
--Delete not allowed
Raise Cant_delete;
End If;
Exception
When Cant_delete Then
Raise_application_error (-20007, ' do not allow delete operation '); The use of--raise_application_error is described in the 07-11-29th log.
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), ' Film and Television Report ');
elsif v_num1 = 0 and v_num2 > 0 Then
: new.content: = replace (: New.content,substr (: new.content,1,v_num2-1), ' Film and Television Report ');
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;
/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.