Using Cursors in Your Code - Aster Client

Teradata Aster® Client Guide

Product
Aster Client
Release Number
7.00
Published
May 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
hki1475000360386.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-2005
lifecycle
previous
Product Category
Software

The driver fetches fetch_count number of rows (as set with Statement.setFetchSize(int rows)) from Aster Database and exposes them to the database application as a “rows” data structure. The default fetch_count is zero, so you must set a fetch_count if you wish to use cursors.

With ResultSet.next(), your application iterates over the rows data structure. When all rows in the rows data structure have been processed, the next call to next() will force the fetching a new set of fetch_count number of rows, and so on.

To use cursors, set the fetch size of your SQL statement using the setFetchSize(int rows) method. Later, setting the fetch_count back to 0 will cause all rows to be retrieved when the query runs (the default behavior).

In the example below, we set the Autocommit setting and the FetchSize setting using the setAutoCommit() and setFetchSize() methods, but you also have the option of setting these in the JDBC connection parameters when you make the connection. See Frequently Used JDBC Setting.