cs_Favorite_Get
ALTER procedure dbo.cs_Favorite_Get
(
@FavoriteType int,
@FavoriteID int
)
AS
SET NOCOUNT ON
/**//*当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数)。
当 SET NOCOUNT 为 OFF 时,返回计数。即使当 SET NOCOUNT 为 ON 时,
也更新 @@ROWCOUNT 函数。*/
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
-----------------------------------------------------------------------
/**//*删除关注的记录,同样还是先判断关注的类型.如果再在不同的表中删除响应的记录
要说明的是这边获取的记录并不仅属于一个人,而其他有点类似的存储过程之所以和这不一
样是 因为他们有的是获取某用户的一条记录等,所以这里 可关注的就是细节了,语法都没什么变.
下面类似,就在这里说下,其他段不说了.*/
------------------------------------------------------------------------
IF @FavoriteType = 1 -- Section
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.SectionID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoriteSections F
WHERE
F.FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 2 -- User
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.UserID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoriteUsers F
WHERE
F.FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 4 -- Post
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.PostID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoritePosts F
WHERE
F.FavoriteID = @FavoriteID
/**//*因为判断后面的语句都挺是照着走的,所以没多注释.*/
GO
ALTER procedure dbo.cs_Favorite_Get
(
@FavoriteType int,
@FavoriteID int
)
AS
SET NOCOUNT ON
/**//*当 SET NOCOUNT 为 ON 时,不返回计数(表示受 Transact-SQL 语句影响的行数)。
当 SET NOCOUNT 为 OFF 时,返回计数。即使当 SET NOCOUNT 为 ON 时,
也更新 @@ROWCOUNT 函数。*/
SET Transaction Isolation Level Read UNCOMMITTED
/**//*设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。*/
-----------------------------------------------------------------------
/**//*删除关注的记录,同样还是先判断关注的类型.如果再在不同的表中删除响应的记录
要说明的是这边获取的记录并不仅属于一个人,而其他有点类似的存储过程之所以和这不一
样是 因为他们有的是获取某用户的一条记录等,所以这里 可关注的就是细节了,语法都没什么变.
下面类似,就在这里说下,其他段不说了.*/
------------------------------------------------------------------------
IF @FavoriteType = 1 -- Section
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.SectionID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoriteSections F
WHERE
F.FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 2 -- User
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.UserID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoriteUsers F
WHERE
F.FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 4 -- Post
SELECT
F.FavoriteID,
F.OwnerID AS UserID,
F.SettingsID,
F.PostID AS ItemID,
@FavoriteType AS FavoriteType,
F.ApplicationType
FROM
cs_FavoritePosts F
WHERE
F.FavoriteID = @FavoriteID
/**//*因为判断后面的语句都挺是照着走的,所以没多注释.*/
GO
cs_Favorite_Delete
ALTER PROCEDURE dbo.cs_Favorite_Delete
(
@FavoriteType int,
@FavoriteID int
)
AS
/**//*判断关注类型,然后再在各表中删除.因为不同的关注是保存在不同的表中的,所以才判断.*/
IF @FavoriteType = 1 -- Section
DELETE
FROM cs_FavoriteSections
WHERE FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 2 -- User
DELETE
FROM cs_FavoriteUsers
WHERE FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 4 -- Post
DELETE
FROM cs_FavoritePosts
WHERE FavoriteID = @FavoriteID
GO
ALTER PROCEDURE dbo.cs_Favorite_Delete
(
@FavoriteType int,
@FavoriteID int
)
AS
/**//*判断关注类型,然后再在各表中删除.因为不同的关注是保存在不同的表中的,所以才判断.*/
IF @FavoriteType = 1 -- Section
DELETE
FROM cs_FavoriteSections
WHERE FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 2 -- User
DELETE
FROM cs_FavoriteUsers
WHERE FavoriteID = @FavoriteID
ELSE IF @FavoriteType = 4 -- Post
DELETE
FROM cs_FavoritePosts
WHERE FavoriteID = @FavoriteID
GO