要求设置一个触发,在数据库中的Task表中加入了一个新task时,同时往Record表中插入一条新记录。我需要在标准匹配task的item表中,对每个开放项目插入一个record。虚拟码如下:
CREATE TRIGGER update_item_records ON INSERT INTO tasks
BEGIN
SELECT item in ITEMS WHERE item.type=new.type AND item.program=new.program
....now insert into records - this is where I'm confused
INSERT INTO records record.item = item.id, record.program = new.program,
record.task=new.id
END