我有一个名为Members
的表和一个名为Lapsed_Members
的表,并希望第一个在删除行后填充第二个。我创建了一个BEFORE DELETE TRIGGER
来处理这个问题(要遵循的代码),我相信这应该有效但是我收到错误通知我有一个
Missing IN or OUT parameter at index:: 2
然而,触发器无法编译:
SQL Error: ORA-04098: trigger 'B0025400.LAPSED_MEMBER_TRIGGER'
任何人都可以帮我解决这个问题吗?
代码:
CREATE or REPLACE TRIGGER lapsed_member_trigger
BEFORE DELETE
ON Members
FOR EACH ROW
BEGIN
INSERT INTO Lapsed_Members
VALUES
(:old.MemberID,
:old.FirstName,
:old.LastName,
:old.DoB,
:old.MemberType,
:old.GroupID,
:old.HouseNo,
:old.Street,
:old.Town,
:old.County,
:old.PostCode,
:old.LastJoined,
sysdate );
END;
此外,虽然我确定它并不重要,但我也试过了
INSERT INTO Lapsed_Members
(StoredMemberID,
FirstName,
LastName)
VALUES
(:old.MemberID,
:old.FirstName,
:old.LastName);
等...
创建表格的脚本:
CREATE TABLE Members(
MemberID number,
FirstName varchar(30),
LastName varchar(30),
DOB date,
MemberType varchar(30),
GroupID number,
HouseNo varchar(30),
Street varchar(30),
Town varchar (30),
County varchar(30),
Postcode varchar(10),
LastJoined date,
constraint Members_PK primary key (MemberID),
constraint Members_FK foreign key (GroupID) references MemberGroups(GroupID)
);
和
CREATE TABLE Lapsed_Members(
StoredMemberID number,
FirstName varchar(30),
LastName varchar(30),
DOB date,
MemberType varchar(30),
GroupID number,
HouseNo varchar(30),
Street varchar(30),
Town varchar (30),
County varchar(30),
Postcode varchar(10),
LastJoined date,
LastLeft date,
constraint Lapsed_Members_PK primary key (LapsedMemberID),
constraint Lapsed_Members_FK foreign key (GroupID) references MemberGroups(GroupID));