Programming Guide


Fetches the next set of data from the database

int sm_tm_command ("FETCH [ tableViewName [ { FETCH_SIMPLE | FETCH_SPECIAL } ] ]");


The name of a table view in the current transaction. The table view must either be a server view or be the server view to which the desired table view belongs. This parameter is case sensitive. If tableViewName is not specified, the command is applied to the root table view.

Start the fetch with the first occurrence. The number of rows fetched depends on the size of the arrays. This is the default parameter if none is specified, or if no table view name is specified.

Allows you to override the occurrence number and the size of the array. To use the FETCH_SPECIAL parameter, you must set the value of TM_OCC and TM_OCC_COUNT with sm_tm_iset before calling this command. When FETCH_SPECIAL is specified, TM_OCC is consulted for the start position and TM_OCC_COUNT is consulted for the count.


FETCH fetches the next set of rows for the specified table view.

If your screen has multiple table views and you want to fetch data for all of them at the same time, use CONTINUE instead of FETCH, since fetch is performed only for the specified table view.

Push buttons and menu selections for the FETCH command can choose to set the class property to continue_button. By default, continue_button is active in view and update modes.


The FETCH command is available after SELECT or VIEW, both of which generate a database query and display the first set of query results.


Table 8-18 Request events for FETCH

Request Traversal Typical Processing


No tree traversal, since performed only for the specified table view



Table 8-19 Slice event processing for FETCH

Slices Typical Processing


A select cursor must have been set up for the server view encompassing the current table view or nothing more is done.

On entry, TM_OCC_COUNT specifies the maximum number of occurrences to be fetched. If TM_OCC_COUNT is zero on entry, it means that there is no explicit limit being imposed. The TM_OCC member on entry specifies the first occurrence to be fetched into.

TM_OCC_COUNT is then zeroed. (At the end of this event, TM_SEL_CHECK sets it to contain the number of rows fetched.)

The data is fetched.

TM_SEL_CHECK is pushed onto the event stack to report the number of rows fetched.


If there was an error in earlier processing, give up the select cursor. Otherwise, report the number of rows fetched to TM_OCC_COUNT.

Give up the select cursor if there are no more rows unless a continuation file is in use.