Returns a row or a set of rows from a cursor result set.
fetch cursor_name [ into fetch_target_list ]
Usage
When the first fetch is received, Component Integration Services constructs the query defined by the declare cursor command and sends it to the remote server.
If the remote server supports Client-Library cursors, Component Integration Services takes the following steps:
Declares a cursor:
ct_cursor(command, CS_CURSOR_DECLARE...)
Establishes the cursor row count:
ct_cursor(command, CS_CURSOR_ROWS,... cursor_row_count)
Opens a Client-Library client cursor to the remote server:
ct_cursor(command, CS_CURSOR_OPEN...)
If the remote server does not support Client-Library cursors, Component Integration Services sends a language request to the server. This may require an additional connection to that server.
If the declare cursor command included a for update clause, the cursor row count is set to 1; otherwise, it is set to the value of the configuration parameter cis_cursor_rows.
After the cursor is opened or the language request is sent, Component Integration Services issues a Client-Library ct_fetch command to obtain the first row. Client-Library array binding is used to establish the buffer in which to place the fetched results, whether Client-Library cursors or language requests are used to generate the fetchable results. The number of rows that are buffered by a single fetch is determined by the cursor row count discussed above.
Subsequent fetch requests retrieve rows from the buffered results, until the end of the buffer is reached. At that time, Component Integration Services issues another Client-Library ct_fetch command to the remote server.
A fetch against a cursor that has no remaining rows in its result set causes Component Integration Services to close the remote cursor.
If the cursor is read only, Component Integration Services sends a language request to the remote server when the first fetch is received after the cursor is opened. Otherwise, Component Integration Services declares a cursor to the remote server by means of Client-Library.
Handling of the fetch statement is the same as for ASEnterprise.
Component Integration Services sends a language request to the remote server when the first fetch is requested after the cursor is opened.
For pre-version 10.0 SQL Server, Component Integration Services sends a language request to the remote server when the first fetch is received after the cursor is opened.
For version 10.0 or later servers, Component Integration Services declares a cursor to the remote server by means of Client-Library.
Component Integration Services treats servers in class direct_connect as if they were version 10.0 or later of class sql_server.
Component Integration Services sends a language request to the remote server when the first fetch is requested after the cursor is opened.
See Also
close, deallocate cursor, declare cursor, open in this chapter.
fetch in the Adaptive Server Reference Manual.