我有一个消息表。在插入消息后,我需要将该插入的 UserID 和 MsgID 插入到 messageRecipient 表中。如果消息被发送到组,则需要将其插入到属于该组的每个用户。这是我所拥有的,但它没有插入到 messageRecipient 表中:
create or replace trigger update_messages
after insert on messages referencing new as new old as old
for each row
declare
userID1 int(10);
msgID1 int(10);
groupID1 int(10);
begin
userID1 := :new.ToUserID;
msgID1 := :new.msgID;
groupID1 := :new.ToGroupID;
if inserting then
if(userID1 <> null)
then INSERT INTO messageRecipient VALUES(msgID1, userID1);
elsif(groupID1 <> null)
THEN INSERT INTO messageRecipient(msgID, userID) SELECT msgID1, userID FROM groupMembership WHERE gID = groupID1;
end if;
end if;
end;
/
这里到底出了什么问题?