Partager via


How to: Return Multiple Result Sets

If you execute a stored procedure that contains native server syntax SELECT statements, each result set is returned to a separate Visual FoxPro cursor. You can use these cursors to return values or parameters from a stored procedure on a remote server to the Visual FoxPro client.

To return multiple result sets

For example, the following code creates and executes a SQL stored procedure on a remote server, my_procedure, that returns three Visual FoxPro cursors: sqlresult, sqlresult1, and sqlresult2:

=SQLEXEC(nConnectionHandle,'create procedure my_procedure as ;
      select * from sales; select * from authors; 
      select * from titles')
=SQLEXEC(nConnectionHandle,'execute my_procedure')

The SQLEXEC( ) Function enables you to send a SQL statement to the data source without interpretation. In the simplest case, any string you enclose in the second parameter of the SQLEXEC( ) function is passed to your data source without interpretation. This allows you to execute any statement using your data source's native SQL.

You can also use the SQLEXEC( ) function to create a parameterized query, or to pass ODBC extensions to SQL to the data source.

See Also

Tasks

How to: Access Stored Procedures on Remote Servers with SQL Pass-Through Functions

How to: Create a Parameterized Query

Other Resources

Using SQL Pass-Through Technology

Enhancing Applications Using SQL Pass-Through Technology

Planning Client/Server Applications

Upsizing Visual FoxPro Databases

Creating Views