我的数据库中有两个实体之间的关系。所以在创建单行之前,我需要删除关系实体中的行,如下所示:
user userHous
id 1 1 2
因此,当我删除用户行时,它应该在触发前执行并删除userHous。
在Mysql中这很容易用我的旧触发器完成:
USE `db`;
DELIMITER $$
CREATE DEFINER=`user`@`ip` TRIGGER `BDEL` BEFORE DELETE ON `user`
FOR EACH ROW
begin
DELETE FROM user WHERE userid = OLD.userid;
DELETE FROM house WHERE userid = OLD.userid;
end
我不确定如何使用{ FOR | AFTER | INSTEAD OF }
我做了这个
CREATE TRIGGER [dbo].[Trigger]
ON [dbo].[user]
INSTEAD OF DELETE
AS
BEGIN
DELETE FROM userHouse WHERE userid = userid;
DELETE FROM user WHERE userid = userid;
END
但是这只删除了两个表中的所有行,我猜是因为我把userid = userid。如何检索构成触发器的查询中的“参数”?
答案 0 :(得分:0)
试试这个
ArrayList<HashMap<Integer,String>> david = new ArrayList<HashMap<Integer,String>>();
david.add(new HashMap<Integer,String>());