Home > Database > Mysql Tutorial > body text

Oracle触发器之before delete

WBOY
Release: 2016-06-07 17:06:01
Original
950 people have browsed it

刚接触Oracle,新建了一个before delete的触发器,但老是报ldquo;警告: 创建的触发器带有编译错误rdquo;,最后发现是触发器里面

刚接触Oracle,,新建了一个before delete的触发器,但老是报“警告: 创建的触发器带有编译错误”,最后发现是触发器里面的语句没有写分号的原因。

下面帖出来,也供新手参考:

1.创建表:

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.触发器--删除Test2中的记录时将其备份到Test3:

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.触发器--删除Test2时同时删除Test1:

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

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template