cs_forums_GetUnmoderatedPostStatus ALTERPROCEDURE[dbo].cs_forums_GetUnmoderatedPostStatus ( @SectionIDint=null, @UserNamevarchar, @SettingsIDint ) AS SETTransactionIsolationLevelReadUNCOMMITTED /**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁, 也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更 改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有 语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/ IF(@SectionID=0) SET@SectionID=null IF(@SectionIDISNull) BEGIN SELECT OldestPostAgeInMinutes =DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue =Count(PostID) FROM cs_Posts P WHERE P.IsApproved =0 AND P.SettingsID =@SettingsID /**//*DATEDIFF 返回跨两个指定日期的日期和时间边界数。 ISNULL 使用指定的替换值替换 NULL。 */ END ELSE BEGIN SELECT OldestPostAgeInMinutes =DateDiff(mi, IsNull(MIN(PostDate),GetDate()),GetDate()),TotalPostsInModerationQueue =Count(PostID) FROM cs_Posts P WHERE P.IsApproved =0 AND P.SettingsID =@SettingsID AND P.SectionID =@SectionID END
cs_forums_GetForumsModeratedByUser ALTERprocedure[dbo].cs_forums_GetForumsModeratedByUser ( @UserNamenvarchar(50), @SettingsIDint ) AS SETTransactionIsolationLevelReadUNCOMMITTED /**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁, 也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更 改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有 语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/ -- determine if this user can moderate ALL forums -- 判断此用户是否有权修改全部论 IFEXISTS(SELECTNULLFROM Moderators (nolock) WHERE SectionID =0AND Username =@UserNameand SettingsID =@SettingsID) /**//*查询符合条件的含有空值的记录,判断这样的记录是否存在*/ SELECT SectionID, ForumName ='All Forums', EmailNotification, DateCreated FROM Moderators (nolock) WHERE SectionID =0AND Username =@UserNameand SettingsID =@SettingsID ELSE -- get all of the forums moderated by this particular user -- 获取此用户的全部操作 SELECT M.SectionID, EmailNotification, ForumName = F.Name, M.DateCreated FROM Moderators M (nolock) INNERJOIN Forums F (nolock) ON F.SectionID = M.SectionID WHERE Username =@UserNameand M.SettingsID =@SettingsIDand F.SettingsID =@SettingsID