Condividi tramite


SQLMORERESULTS( ) Function

Copies another result set to a Visual FoxPro cursor if more result sets are available.

SQLMORERESULTS(nStatementHandle [, cCursorName [, aCountInfo]]))

Parameters

  • nStatementHandle
    Specifies the statement handle to the data source returned by SQLCONNECT( ).

  • cCursorName
    Specifies the name of the Visual FoxPro cursor to which the result set is sent. If you do not include a cursor name, Visual FoxPro uses the default name SQLRESULT.

    For multiple result sets, new cursor names are derived by appending an incremented number to the name of the first cursor.

  • aCountInfo
    Specifies the name of the array to populate with row count information. If the array doesn’t exist, it is created. The array has two columns: 1 – Alias, 2 –Count.

    Column

    Array contents

    Data type

    Description

    Alias

    0

    Character

    Indicates that SQL command did not return any results. Either no records were returned or the SQL command failed before results could be returned. (final SQLMORERESULTS call) or execution failed before any result could be processed. Can be only on the first row. Count column for the row contains value -1.

    Non-empty uppercase string

    Character

    Alias of the cursor – target for the record fetch operation. The Count column for the row contains the number of fetched records or -1 if fetch failed. If Count is -1, cursor may not have been created. During asynchronous execution, the fetch process for a cursor can be split between multiple SQLMORERESULTS or SQLEXEC calls; each call returns its own fetch count for the cursor.

    Empty String

    Character

    Indicates that the SQL command (INSERT, UPDATE, or DELETE) did not return a result set.

    Count

    Number of affected or fetched records.

    Integer

    Indicates the number of affected records as returned by the ODBC SQLRowCount function.

    Returns -1 if the number of records is unavailable.

Return Value

Numeric. SQLMORERESULTS( ) returns 0 if the SQL statement is still executing, returns 1 if it is finished executing, and returns 2 if no more data is found. In non-batch mode, SQLMORERESULTS( ) should be called after each successful SQLEXEC( ) call until SQLMORERESULTS( ) returns 2 (no more data found). The setting of the SQLSETPROP( ) batch mode option determines whether SQLEXEC( ) executes a SQL statement in batch or non-batch mode.

SQLMORERESULTS( ) returns – 1 if a connection level error occurs, and returns – 2 if an environment level error occurs.

Remarks

SQLMORERESULTS( ) determines if more result sets are available from a SQL statement executed with SQLEXEC( ) in non-batch mode. If more result sets are available, they are copied to a Visual FoxPro cursor, one set at a time.

SQLMORERESULTS( ) is one of the four functions that you can execute either synchronously or asynchronously. The asynchronous setting of SQLSETPROP( ) determines if these functions execute synchronously or asynchronously. In asynchronous mode, you must call SQLMORERESULTS( ) repeatedly until it returns a value other than 0 (still executing).

Example

The following example assumes SQLCONNECT( ) is successfully issued, and its return value is stored to a memory variable named gnHandle. SQLSETPROP( ) is used to set the BatchMode property to False (.F.) so the individual result sets can be retrieved.

SQLMORERESULTS( ) is issued twice to create two cursors containing the results of the SQLEXEC( ) query. SET is used to display the View window and the cursors created by SQLEXEC( ).

= SQLSETPROP(gnHandle, 'BatchMode', .F.)  && Individual result sets
= SQLEXEC(gnHandle, 'SELECT * FROM authors;
   SELECT * FROM titles')
= SQLMORERES(gnHandle)  && First result set
= SQLMORERES(gnHandle)  && Second result set

See Also

Reference

AERROR( ) Function

SQLCANCEL( ) Function

SQLCONNECT( ) Function

SQLEXEC( ) Function

SQLGETPROP( ) Function

SQLSETPROP( ) Function

SQL Commands and Functions

Other Resources

Language Reference (Visual FoxPro)