Download Informix CLI Programmer`s Manual, Version 2.5

Transcript
SQLFetch
Usage
SQLFetch positions the cursor on the next row of the result set. Before
SQLFetch is called the first time, the cursor is positioned before the start of
the result set. When the cursor is positioned on the last row of the result set,
SQLFetch returns SQL_NO_DATA_FOUND, and the cursor is positioned after
the end of the result set. An application cannot mix calls to SQLExtendedFetch and SQLFetch for the same cursor.
If the application called SQLBindCol to bind columns, SQLFetch stores data
into the locations specified by the calls to SQLBindCol. If the application does
not call SQLBindCol to bind any columns, SQLFetch does not return any
data; it moves the cursor to the next row. An application can call SQLGetData
to retrieve data that is not bound to a storage location.
The driver manages cursors during the fetch operation and places each value
of a bound column into the associated storage. The driver follows these
guidelines when it performs a fetch operation:
■
SQLFetch accesses column data in left-to-right order.
■
After each fetch, pcbValue (specified in SQLBindCol) contains the
number of bytes that are available to return for the column. This is
the number of bytes that are available prior to calling SQLFetch. If
the number of bytes that are available to return cannot be determined in advance, the driver sets pcbValue to SQL_NO_TOTAL. (If
SQL_MAX_LENGTH has been specified with SQLSetStmtOption and
the number of bytes that are available to return is greater than
SQL_MAX_LENGTH, pcbValue contains SQL_MAX_LENGTH.)
Tip: The SQL_MAX_LENGTH statement option is intended to reduce network traffic
and might not be supported by all drivers. To guarantee that data is truncated, an
application should allocate a buffer of the desired size and specify this size in the
cbValueMax argument.
13-148
■
If rgbValue cannot hold the entire result, the driver stores part of the
value and returns SQL_SUCCESS_WITH_INFO. A subsequent call to
SQLError indicates that a truncation occurred. The application can
compare pcbValue to cbValueMax (specified in SQLBindCol) to
determine which column or columns were truncated. If pcbValue is
greater than or equal to cbValueMax, then truncation occurred.
■
If the data value for the column is NULL, the driver stores
SQL_NULL_DATA in pcbValue.
INFORMIX-CLI Programmer’s Manual