Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# getNextPage() and getPreviousPage()

You can use the `Database.getNextPage()` and `Database.getPreviousPage()` functions to access next or previous pages respectively from the database cursor.

The `getPreviousPage()`function fetches records in the forward direction. That is, if the cursor is on the 11th record and you call this function, it returns records from 1 to 10, and not from 10 to 1.

The `getNextPage()` function returns an empty array when it reaches the end of the result set. Similarly, the `getPreviousPage()` function returns an empty array when it reaches the beginning of the result set.

## Syntax

    Object [] getNextPage(String cursorName, int pageSize)
    Object [] getPreviousPage(String cursorName, int pageSize)

## Parameters

Parameter | Type | Description
--- | --- | ---
`cursorName` | `String` | The name of the database cursor.
`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 getNextPage

    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.getNextPage(cursorName, 10);
       System.debugOut(" Database.getNextPage() fetched " + empCepts@length + " rows");

## Example for getPreviousPage

    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. getPreviousPage (cursorName, 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.