Compartir a través de


SETRESULTSET( ) Function

Marks a cursor as a result set in the current data session.

Note

Only one cursor per data session can be marked. When marking a new cursor, SETRESULTSET( ) clears the marker from any previously marked cursor.

SETRESULTSET( nWorkArea | cTableAlias )

Parameters

  • nWorkArea
    Specifies a work area number.

  • cTableAlias
    Specifies the alias of the cursor you want to mark.

Return Value

Numeric. SETRESULTSET( ) returns the number of the work area of the previously marked cursor in the current data session or zero (0) if no cursor is marked in the current data session.

Remarks

SETRESULTSET( ) is supported in Visual FoxPro and the Visual FoxPro OLE DB Provider. You can use SETRESULTSET( ) in a database container (DBC) stored procedure or send it to the Visual FoxPro OLE DB Provider, assuming that the cursor has been previously opened by the OLE DB Provider. For example, suppose a previous command opens a cursor named MyCursor in the OLE DB Provider. The following line of code retrieves an ADO RecordSet for the cursor, MyCursor:

oRecordSet = oConn.Execute("SETRESULTSET('MyCursor')")

By using SETRESULTSET( ) to mark a cursor or table opened by the Visual FoxPro OLE DB Provider, you can retrieve a rowset created from the table or cursor from a database container (DBC) stored procedure. When the OLE DB Provider completes command execution, it creates a rowset from the marked cursor, if it exists, then clears the marker flag from the cursor.

Note

In this scenario, the OLE DB Provider disregards all other return values. For example, if a stored procedure contains a RETURN Value statement and a marked cursor, the OLE DB Provider does not return the value. Instead, it returns the marked cursor as a rowset to the calling application. When the rowset closes, the cursor also closes.

However, even though the OLE DB Provider disregards all return values when a marked cursor exists, you can use SETRESULTSET( ) with the RETURN command. For example:

RETURN SETRESULTSET("MyCursor")

This statement creates and returns a rowset from the marked cursor, not the return value from SETRESULTSET( ).

See Also

Tasks

How to: Use Data Sessions

Reference

GETRESULTSET( ) Function

CLEARRESULTSET( ) Function

Supported Visual FoxPro Commands and Functions in OLE DB Provider

Other Resources

Functions