📄 trigger.sql
字号:
-- ================ Post Trigger ================
-- Description:Set ParentId and Times when Posted
-- Author:kid
-- ==============================================
CREATE TRIGGER Trig_Forum_Info
ON Forum_Info
WITH ENCRYPTION
for insert
as
begin
declare @id int
declare @Parentid int
select @id=Forum_Info_Id from inserted
select @Parentid=Forum_Info_ParentId from inserted
update Forum_Info set Forum_Info_RootId=@id where Forum_Info_Id=@id and @Parentid=0
Update Forum_Info set Forum_Info_Times=@id
where Forum_Info_RootId= @id and @Parentid=0
update Forum_Info set Forum_Info_RootId=
(select top 1 Forum_Info_RootId from Forum_Info where Forum_Info_Id=@Parentid)
where Forum_Info_Id=@id and @Parentid<>0
Update Forum_Info set Forum_Info_Times=@id
where Forum_Info_RootId= (select top 1 Forum_Info_RootId from Forum_Info where Forum_Info_Id=@Parentid) and @Parentid<>0
end
-- ================== BookMarks Trigger ==================
-- Description:Set BookMark Name when BookMarks been Added
-- Author:kid
-- =======================================================
CREATE TRIGGER Trig_Forum_BookMarks
ON Forum_BookMarks
WITH ENCRYPTION
for insert
as
begin
declare @Title varchar(255)
declare @id int
select @id=Forum_Info_Id from inserted
select @Title=Forum_Info_Title from Forum_Info where Forum_Info_Id=@id
update Forum_BookMarks set Forum_BookMark_Name=@Title,Forum_BookMark_Des=@Title where Forum_Info_Id=@id
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -