Fetching rows methods

 

These methods are used for fetching rows from database tables using an initialized CURSOR variable.

 

These methods are synonymous to the FETCH statement. The CURSOR variable must be declared (see declare() and open()) before it can be used with the fetching methods.

 

Fetching methods can be used only with a cursor declared for a SELECT statement.

 

Fetching methods return sqlca.sql code that is 0 if a row was properly fetched, and 100 if the NOT FOUND condition occurred. If an error occurred while fetching a row, these methods will return a negative number with the error code.

 

Fetching methods are invoked in the following way:

 

CALL cur_v.<Method>(<parameters>)

 

fetchNext()

consequently fetches the rows from the active set

fetchPrevious()

fetches the previous row from the active set

fetchFirst()

fetches the first row from the active set

fetchLast()

fetches the last row from the active set

fetchRelative()

fetches the row specified with a current cursor position

fetchAbsolute()

fetches the row from the active set regardless of cursor position