SQLQueryFetch

Syntax

SQLQueryFetch(ConnectNum)

Remarks

Positions the cursor at the next row of data in the query result of SQLQueryExec. The cursor cannot be moved backward. To use SQLQueryFetch, a macro must have already established a connection using SQLOpen. Also, a query must have already been executed using SQLQueryExec, and results must be pending.

Use SQLQueryRetrieve to return data from the row of data at which the cursor is positioned.

You cannot use SQLQueryFetch in combination with SQLRetrieveItem$ or SQLRetrieveToDocument to return data from a data source.

Argument

Explanation

ConnectNum

The unique connection ID for a data source. The data source specified must have pending query results. If ConnectNum is not valid, SQLQueryExec would have returned an error value. In such a case, SQLQueryExec places error information in memory for the error functions, if such information is available.


If the cursor was moved, SQLQueryFetch returns 1; if the cursor is already positioned at the last row of data, it returns –1 (SQL_NoMoreData). Otherwise, SQLQueryFetch returns 0 (zero) or a negative error value.

Example

The following example uses a While...Wend loop to return the data in each column of each row of the pending data source until SQLQueryFetch returns a value indicating that the cursor is already at the last row of the query results.


cols = SQLRetrieveColumns(connect_no)
ret = SQLQueryFetch(connect_no)
While ret = 1
    For i = 1 To cols
        storsize = SQLRetrieveColSize(connect_no, i)
        stor$ = String$(storsize, 50)
        SQLQueryRetrieve(connect_no, i, stor$, storsize)
        ' Statement block that processes the value of stor$
    Next i
ret = SQLQueryFetch(connect_no)
Wend