我有一张Links
带有字段名称的表
[PUBLICATION_ID],
[PAGE_ID],
[COMPONENT_ID],
[COMPONENT_TEMPLATE_ID],
[COMPONENT_TEMPLATE_PRIORITY],
[COMPONENT_POSITION],[URL]
在数据库中Tridion_Broker
我想在插入/更新时创建一个 SQL 触发器,它将从“链接”表中获取字段的数据[PUBLICATION_ID], [URL]
并将其放入不同的数据库 ( GoogleLinks
) 和表中MyLinks
。
编辑:
我的实现如下:
DROP TRIGGER IF EXISTS Update_Google_List;
DELIMITER $$
CREATE TRIGGER Update_Google_List AFTER INSERT , UPDATE
ON Tridion_Broker.dbo.Links
FOR EACH ROW
BEGIN
INSERT INTO GoogleLinks.dbo.MyLinks (PUBLICATION_ID, URL)
SELECT DISTINCT PUBLICATION_ID as n,URL as u
FROM Tridion_Broker.dbo.Links
WHERE Page_ID =@PageID
AND Component_Template_Priority >0
AND PUBLICATION_ID NOT IN(232,481)
AND NOT EXISTS (SELECT 1
FROM MyLinks as g
WHERE g.PUBLICATION_ID = Links.PUBLICATION_ID
)
ORDER BY PUBLICATION_ID
END$$
DELIMITER ;