Oracle trigger-beforedelete

Source: Internet
Author: User
A beforedelete trigger was created when I first came into contact with Oracle, but ldquo was always reported. Warning: the trigger was created with the compilation error rdquo. Finally, it was found that it was in the trigger.

A before delete trigger was created when I first came into contact with Oracle, but ldquo was always reported. Warning: the trigger was created with a compilation error rdquo. Finally, it was found that it was inside the trigger.

When I first came into contact with Oracle, I created a before delete trigger, but always reported "Warning: The created trigger has a compilation error". Finally, I found that the statement in the trigger did not write a semicolon.

The following post is also for reference:

1. Create a table:

Create table test1 (CardID number, Name NVARCHAR2 (20), Sex NUMBER );
Create table test2 (CardID number, Name NVARCHAR2 (20 ));
Create table test3 (CardID number, Name NVARCHAR2 (20 ));

2. Trigger -- back up the record in Test2 to Test3 When deleting it:

Create or replace trigger Trig_Del_Backup
After delete
On test2
For each row
Declare
-- Fdsfaf
Begin
Insert into test3 values (: old. cardid,: old. name );
End
;
/

3. Trigger -- delete Test1 When deleting Test2:

Create or replace trigger Trig_Del
After delete
On test2
For each row
Declare
-- Fdsfaf
Begin
Delete from test1 where CardID =: old. CardID and Name =: old. name;
End
;
/

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.