zoukankan
html css js c++ java
cs_forums_Moderate_PostSet
cs_forums_Moderate_PostSet
ALTER
PROCEDURE
dbo.cs_forums_Moderate_PostSet
(
@SectionID
int
,
@PageIndex
int
,
@PageSize
int
,
@SortBy
int
,
@SortOrder
bit
,
@UserID
int
,
@ReturnRecordCount
bit
,
@SettingsID
int
)
AS
SET
Transaction
Isolation
Level
Read
UNCOMMITTED
/**/
/*
设置事务隔离级别,Read UNCOMMITTED 执行脏读或 0 级隔离锁定,这表示不发出共享锁,
也不接受排它锁。当设置该选项时,可以对数据执行未提交读或脏读;在事务结束前可以更
改数据内的数值,行也可以出现在数据集中或从数据集消失。该选项的作用与在事务内所有
语句中的所有表上设置 NOLOCK 相同。这是四个隔离级别中限制最小的级别。
*/
BEGIN
DECLARE
@PageLowerBound
int
DECLARE
@PageUpperBound
int
DECLARE
@ThreadID
int
--
Set the page bounds
--
设置页面绑定
SET
@PageLowerBound
=
@PageSize
*
@PageIndex
SET
@PageUpperBound
=
@PageLowerBound
+
@PageSize
+
1
--
Create a temp table to store the select results
--
创建个临时表来存储查询结果(为页面绑定用的)
CREATE
TABLE
#PageIndex
(
IndexID
int
IDENTITY
(
1
,
1
)
NOT
NULL
,
PostID
int
)
--
Sort by Post Date
--
按回帖日期排序
IF
@SortBy
=
0
AND
@SortOrder
=
0
INSERT
INTO
#PageIndex (PostID)
SELECT
PostID
FROM
cs_Posts P (nolock)
WHERE
IsApproved
=
0
AND
SectionID
=
@SectionID
and
SettingsID
=
@SettingsID
ORDER
BY
PostDate
ELSE
IF
@SortBy
=
0
AND
@SortOrder
=
1
INSERT
INTO
#PageIndex (PostID)
SELECT
PostID
FROM
cs_Posts P (nolock)
WHERE
IsApproved
=
0
AND
SectionID
=
@SectionID
and
SettingsID
=
@SettingsID
ORDER
BY
PostDate
DESC
--
Select the individual posts
--
查询个人的帖子
SELECT
P.PostID, P.ThreadID, P.ParentID, P.PostAuthor, P.UserID, P.SectionID, P.PostLevel, P.SortOrder, P.Subject, P.PostDate, P.IsApproved,
P.IsLocked, P.IsIndexed, P.TotalViews, P.Body, P.FormattedBody, P.IPAddress, P.PostType, P.EmoticonID, P.SettingsID, P.AggViews,
P.PropertyNames
as
PostPropertyNames, P.PropertyValues
as
PostPropertyValues,
P.PostConfiguration,P.UserTime, P.ApplicationPostType, P.PostName,
P.Points
as
PostPoints, P.RatingSum
as
PostRatingSum, P.TotalRatings
as
PostTotalRatings,
T.
*
, U.
*
, #PageIndex.
*
,
T.IsLocked,
T.IsSticky,
Username
=
P.PostAuthor,
EditNotes
=
(
SELECT
EditNotes
FROM
cs_PostEditNotes
WHERE
PostID
=
P.PostID),
AttachmentFilename
=
ISNULL
( (
SELECT
[
FileName
]
FROM
cs_PostAttachments
WHERE
PostID
=
P.PostID),
''
),
Replies
=
(
SELECT
COUNT
(P2.PostID)
FROM
cs_Posts P2 (nolock)
WHERE
P2.ParentID
=
P.PostID
AND
P2.PostLevel
!=
1
),
IsModerator
=
(
SELECT
count
(UserID)
from
cs_Moderators
where
UserID
=
@UserID
),
HasRead
=
0
--
not used
FROM
cs_Posts P (nolock),
cs_Threads T,
cs_vw_Users_FullUser U,
#PageIndex
WHERE
P.PostID
=
#PageIndex.PostID
AND
P.UserID
=
U.cs_UserID
AND
T.ThreadID
=
P.ThreadID
AND
#PageIndex.IndexID
>
@PageLowerBound
AND
#PageIndex.IndexID
<
@PageUpperBound
and
U.SettingsID
=
@SettingsID
ORDER
BY
IndexID
END
查看全文
相关阅读:
LeetCode | Construct Binary Tree from Inorder and Postorder Traversal
LeetCode | Construct Binary Tree from Preorder and Inorder Traversal
LeetCode | Binary Tree Zigzag Level Order Traversal
PLI与Pillow
CentOS下安装setuptools、pip和virtualenv
CentOS下更新python版本
CentOS中输入yum报错:sudo: unable to execute /bin/yum: No such file or directory
Python中pip版本升级error:You are using pip version 7.1.2, however version 8.1.1 is available.
CentOS安装git
CentOS中yum安装软件时报错:No package XXX available
原文地址:https://www.cnblogs.com/ruanbl/p/509713.html
最新文章
SSM-SpringMVC-20:SpringMVC中处理器方法之返回值void篇
SSM-SpringMVC-19:SpringMVC中请求和响应的乱码解决
SSM-SpringMVC-17:SpringMVC中深度剖析HandlerAdapter处理器适配器底层
Linux内核之进程和文件共享
shell script 零碎知识
Linux08--Shell程序设计03 shell script
Linux07--Shell程序设计03 通配符与正则表达式
Linux06--Shell程序设计02 数据流重定向与管道
Android07-Android广播
Android06-Fragment碎片
热门文章
链表逆序 和 寻找链表中间节点
二叉树的遍历--递归及非递归实现
不调用库函数实现 strCpy
LeetCode | Linked List Cycle II
LeetCode | Linked List Cycle
LeetCode | Best Time to Buy and Sell Stock III
LeetCode | Best Time to Buy and Sell Stock II
LeetCode | Best Time to Buy and Sell Stock
LeetCode | Single Number II
LeetCode | Single Number
Copyright © 2011-2022 走看看