If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Displaying Records Page Wise.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-08, 00:18
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
Displaying Records Page Wise.

Hi ,

Need to display records in sybase for first 10 and then next 10 and so on.

Don't want to do this via cursors.Is there a another way to get it done.


Thanks,
Dinesh
Reply With Quote
  #2 (permalink)  
Old 05-19-08, 11:46
samirbadhe samirbadhe is offline
Registered User
 
Join Date: May 2008
Posts: 10
RE:Displaying Records Page Wise.

hi Dinesh,

Try something like below. This SP takes the page number as an argument
and should give return back, rows to be displayed on that page.

create proc getPageWiseData
(
@pageNo int --# Pass the page number as an argument.
)
as
BEGIN
--# Page size defines the number of rows you are planning to show per page.
declare @pageSize int
select @pageSize = 10

--# variable to hold the first row number of the page.
declare @from int
select @from = ( @pageNo * @pageSize ) - ( @pageSize - 1 )

--# variable to hold last row number of the page.
declare @to int
select @to = ( @pageNo * @pageSize )

--# get the data into a temp table, with simulated rownum.
select rownum = identity(10) , * into #dataWithRownum from yourTable

--# select the data with the calculated range for first and last row on page.
select * from #dataWithRownum where rownum >= @from and rownum <= @to

END

You can further modifiy this SP, to according to your requirements.

I have also added this to my SQL blog - pagination in sybase
;-)
__________________
-samir
TechFruits.com
Reply With Quote
  #3 (permalink)  
Old 05-19-08, 23:26
dinjo_jo dinjo_jo is offline
Registered User
 
Join Date: May 2008
Posts: 34
Thanks Samir it helped.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On