SQLSetRowPos

Syntax

SQLSetRowPos(ConnectNum, Row)

Remarks

Positions the cursor at a specified row of the query results of SQLQueryExec. To use SQLSetRowPos, 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.

Note

Not all DBMSs can move the cursor to an arbitrary row of a query result. If a SQLOpen instruction returned a connection to a DBMS that cannot use move the cursor arbitrarily, SQLSetRowPos returns 0 (zero).

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

You cannot use SQLSetRowPos to return data from a SQLExecQuery instruction.

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, SQLSetRowPos places error information in memory for the error functions, if such information is available.

Row

The number of a row in the data source. If the row value is out of range, SQLSetRowPos returns 0 (zero).

You cannot use SQLRetrieveRows to determine the number of rows in a query result from a SQLQueryExec instruction. Therefore, you must use one of the following two methods to determine valid values for Row:

Create a While...Wend loop to call SQLQueryFetch and increment a counter variable until SQLQueryFetch returns –1. Then use any value between 1 and the counter variable for Row.

Use any value and then determine whether SQLQueryFetch succeeded: if it didn't, try another value; if it did, process the data in the row at which the cursor was successfully positioned.


If the cursor was moved, SQLSetRowPos returns 1. If an error occurred, SQLSetRowPos returns 0 (zero) or a negative error value.

If the DBMS specified by the SQLOpen instruction that returned ConnectNum does not support this functionality, SQLSetRowPos returns 0 (zero).