Click or drag to resize

SqlMoreResults Function

X#
Copies another result set to a X# cursor if more result sets are available.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION SqlMoreResults(
	nStatementHandle AS LONG,
	 cCursorName AS USUAL,
	 aCountInfo AS USUAL
) AS LONG
Request Example View Source

Parameters

nStatementHandle
Type: Long
Specifies the statement handle to the data source returned by SqlConnect( ).
cCursorName
Type: Usual
Specifies the name of the X# cursor to which the result set is sent. If you do not include a cursor name, X# 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
Type: Usual

Return Value

Type: Long
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 X# 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).
ColumnArray contentsData typeDescription
Alias0Character 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 stringCharacter 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.
CharacterEmpty StringIndicates that the SQL command (Insert, UPDATE, or DELETE) did not return a result set.
CountNumber of affected or fetched records.IntegerIndicates the number of affected records as returned by the ODBC SQLRowCount function. Returns -1 if the number of records is unavailable.
Examples
X#
1= SqlSetProp(gnHandle, 'BatchMode', .F.)  // Individual result sets
2= SqlExec(gnHandle, 'Select * From authors;
3Select * From titles')
4= SqlMoreRes(gnHandle)  // First result set
5= SqlMoreRes(gnHandle)  // Second result set
See Also