Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# getNextPageFromOffset() and getPreviousPageFromOffset()

While paging a result set, you can skip a number of rows or records. This set of records to be skipped is called an Offset. Use the `Database.getNextPageFromOffset()` and `Database.getPreviousPageFromOffset()` functions to get the next or previous pages respectively of the database cursor, starting from an offset.

## Syntax

    Object [] getNextPageFromOffset(String cursorName, int startOffset, int pageSize)
    Object [] getPreviousPageFromOffset (String cursorName, int startOffset, int pageSize)

## Parameters

Parameter | Type | Description
--- | --- | ---
`cursorName` | `String` | The name of the database cursor.
`startOffset` | `Integer` | The start offset for the page.
`pageSize` | `Integer` | The number of concepts or records to be fetched from the database for each page. If the `pageSize` is -1, then the default page size given for the cursor is used. The default is 500.
`return Object[]` | `Object[]` | The array of the returned resultset data. If `resultConceptURI` is specified, the array is of `resultConceptType`. Else, it is in the form of n-tuple object array, where each tuple is an array of the values of the returned resultset data.

## Example for getNextPageFromOffset

    Database.setCurrentConnection("/SharedResources/Oracle.sharedjdbc");
    String jdbcURI="/SharedResources/HR_DB_Conn.sharedjdbc";
    String cursorName="EmpCursor";
    String resultTypeURI="/Concepts/HR/EMPLOYEES";
    String sql="select * from employees";
    int pageSize=10 ;
    Object requestObj=null;
    String cursorName=Database.createQuery(jdbcURI,cursorName,resultTypeURI,sql,pageSize,requestObj);
    System.debugOut(" Opened Cursor: " + cursorName);
    Concept[] empCepts={};
    empCepts=Database.getNextPageFromOffset(cursorName,2,10);
    System.debugOut(" Database. getPreviousPage () fetched " + empCepts@length + " rows");

## Example for getPreviousPageFromOffset

    Database.setCurrentConnection("/SharedResources/Oracle.sharedjdbc");
    String jdbcURI="/SharedResources/HR_DB_Conn.sharedjdbc";
    String cursorName="EmpCursor";
    String resultTypeURI="/Concepts/HR/EMPLOYEES";
    String sql="select * from employees";
    int pageSize=10 ;
    Object requestObj=null;
    String cursorName=Database.createQuery(jdbcURI,cursorName,resultTypeURI,sql,pageSize,requestObj);
    System.debugOut(" Opened Cursor: " + cursorName);
    Concept[] empCepts={};
    empCepts=Database.getPreviousPageFromOffset(cursorName,5,10);
    System.debugOut(" Database. getPreviousPage () fetched " + empCepts@length + " rows");

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.