Results 1 to 3 of 3
  1. #1
    Join Date
    May 2008
    Posts
    35

    Unanswered: 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

  2. #2
    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
    ;-)

  3. #3
    Join Date
    May 2008
    Posts
    35
    Thanks Samir it helped.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •