Copy codeThe Code is as follows:
Create procedure sp_pageQuery
@ Sqlstr nvarchar (4000 ),
@ Page_index int,
@ Page_size int,
@ Rec_count int out --
As
Set nocount on
Declare @ cursor_id int
Declare @ rowcount int
Exec sp_cursoropen @ cursor_id output, @ sqlstr, @ scrolopt = 1, @ ccopt = 1, @ rowcount = @ rowcount output
Set @ rec_count = @ rowcount
Set @ page_index = (@ page_index-1) * @ page_size + 1
IF @ rec_count> 0
BEGIN
Exec sp_cursorfetch @ cursor_id, 16, @ page_index, @ page_size
END
ELSE
BEGIN
Select 'test' = 'null' Where 1 = 2
END
Exec sp_cursorclose @ cursor_id
Set nocount off
GO
Call
Copy codeThe Code is as follows:
Create PROCEDURE [dev]. [P_Mobile_Comment_Page]
@ Course_ware_id int,
@ RecCountPerPage int = 1,
@ PageIndex int = 1,
@ RecordCount int = 0 out
AS
DECLARE @ SQL nvarchar (4000)
SET @ SQL ="
Select seg_id, course_ware_id, subject, cust_name, content, create_date
FROM T_COURSEWARE_COMMENT
Where course_ware_id = "+ cast (@ course_ware_id as varchar (10) +"
Order by seg_id"
EXEC sp_Pagequery @ SQL, @ pageIndex, @ recCountPerPage, @ recordCount out
GO