cs_Groups_ResetOrder
ALTER Proc [dbo].cs_Groups_ResetOrder
(
@ApplicationType int,
@SettingsID int
)
as
Declare @Sort int -- 声明类型
Set @Sort = 0 -- 设初值为0
Declare @GroupID int --声明组ID
DECLARE group_Cursor CURSOR FOR --游标
SELECT GroupID FROM cs_Groups where ApplicationType = @ApplicationType and SettingsID = @SettingsID order by SortOrder
OPEN group_Cursor
FETCH NEXT FROM group_Cursor Into @GroupID
WHILE (@@FETCH_STATUS = 0)
Begin
Update cs_Groups Set SortOrder = @Sort where GroupID = @GroupID
Set @Sort = @Sort + 1
FETCH NEXT FROM group_Cursor Into @GroupID
End
CLOSE group_Cursor
DEALLOCATE group_Cursor
/**//*DEALLOCATE 删除游标引用。当释放最后的游标引用时,组成该游标的数据结构由
Microsoft? SQL Server? 释放*/
ALTER Proc [dbo].cs_Groups_ResetOrder
(
@ApplicationType int,
@SettingsID int
)
as
Declare @Sort int -- 声明类型
Set @Sort = 0 -- 设初值为0
Declare @GroupID int --声明组ID
DECLARE group_Cursor CURSOR FOR --游标
SELECT GroupID FROM cs_Groups where ApplicationType = @ApplicationType and SettingsID = @SettingsID order by SortOrder
OPEN group_Cursor
FETCH NEXT FROM group_Cursor Into @GroupID
WHILE (@@FETCH_STATUS = 0)
Begin
Update cs_Groups Set SortOrder = @Sort where GroupID = @GroupID
Set @Sort = @Sort + 1
FETCH NEXT FROM group_Cursor Into @GroupID
End
CLOSE group_Cursor
DEALLOCATE group_Cursor
/**//*DEALLOCATE 删除游标引用。当释放最后的游标引用时,组成该游标的数据结构由
Microsoft? SQL Server? 释放*/
cs_Groups_ReOrder
ALTER Proc [dbo].cs_Groups_ReOrder
(
@GroupID int,
@Index int,
@SettingsID int
)
as
Set NoCount On
/**//*当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数)。当 SET
NOCOUNT 为 OFF 时,返回计数。即使当 SET NOCOUNT 为 ON 时,也更新 @@ROWCOUNT 函数。*/
Declare @ApplicationType int
Select @ApplicationType = ApplicationType From cs_Groups where GroupID = @GroupID and SettingsID = @SettingsID
exec cs_Groups_ResetOrder @ApplicationType, @SettingsID
update cs_Groups
Set SortOrder = SortOrder + 1 where SortOrder >= @Index and SettingsID = @SettingsID and ApplicationType = @ApplicationType
update cs_Groups
Set SortOrder = @Index where GroupID = @GroupID and SettingsID = @SettingsID and ApplicationType = @ApplicationType
exec cs_Groups_ResetOrder @ApplicationType, @SettingsID
ALTER Proc [dbo].cs_Groups_ReOrder
(
@GroupID int,
@Index int,
@SettingsID int
)
as
Set NoCount On
/**//*当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数)。当 SET
NOCOUNT 为 OFF 时,返回计数。即使当 SET NOCOUNT 为 ON 时,也更新 @@ROWCOUNT 函数。*/
Declare @ApplicationType int
Select @ApplicationType = ApplicationType From cs_Groups where GroupID = @GroupID and SettingsID = @SettingsID
exec cs_Groups_ResetOrder @ApplicationType, @SettingsID
update cs_Groups
Set SortOrder = SortOrder + 1 where SortOrder >= @Index and SettingsID = @SettingsID and ApplicationType = @ApplicationType
update cs_Groups
Set SortOrder = @Index where GroupID = @GroupID and SettingsID = @SettingsID and ApplicationType = @ApplicationType
exec cs_Groups_ResetOrder @ApplicationType, @SettingsID
cs_Groups_Get
ALTER PROCEDURE [dbo].cs_Groups_Get
(
@SettingsID int,
@ApplicationType smallint = 0,
@RequireModeration bit = 0 -- 不知道是不是操作要求的意思
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
IF (@RequireModeration = 0)
SELECT
*
FROM
cs_Groups
WHERE
(SettingsID = @SettingsID) and ApplicationType = @ApplicationType
/**//*按输入的参数进行操作*/
ELSE
SELECT DISTINCT
FG.*
FROM
cs_Sections S,
cs_Groups FG
WHERE
S.GroupID = FG.GroupID AND
S.IsActive = 1 AND
(SELECT Count(PostID) FROM cs_Posts P WHERE SectionID = S.SectionID AND P.IsApproved = 0) > 0 AND
(FG.SettingsID = @SettingsID) AND
FG.ApplicationType = @ApplicationType
END
ALTER PROCEDURE [dbo].cs_Groups_Get
(
@SettingsID int,
@ApplicationType smallint = 0,
@RequireModeration bit = 0 -- 不知道是不是操作要求的意思
)
AS
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
BEGIN
IF (@RequireModeration = 0)
SELECT
*
FROM
cs_Groups
WHERE
(SettingsID = @SettingsID) and ApplicationType = @ApplicationType
/**//*按输入的参数进行操作*/
ELSE
SELECT DISTINCT
FG.*
FROM
cs_Sections S,
cs_Groups FG
WHERE
S.GroupID = FG.GroupID AND
S.IsActive = 1 AND
(SELECT Count(PostID) FROM cs_Posts P WHERE SectionID = S.SectionID AND P.IsApproved = 0) > 0 AND
(FG.SettingsID = @SettingsID) AND
FG.ApplicationType = @ApplicationType
END