Compartir a través de


How to: Store Query Results in a Table, Array, or Cursor

You can store your query results in a table, array, or cursor for other uses such as populating forms and printing reports and labels. If you want to store the results only temporarily, send the results to an array or cursor. If you want to store the results permanently, send the results to a table.

To specify a table as the destination

  • Use the INTO clause of the SELECT - SQL statement to specify a destination.

The following example shows an INTO clause for a table:

SELECT * ;
   FROM tastrade!customer ;
   WHERE customer.country = "Canada" ;
   INTO TABLE mytable

To specify an array as the destination

  • Use the INTO clause of the SELECT - SQL statement to specify a destination.

The following example shows an INTO clause for an array:

SELECT * ;
   FROM tastrade!customer ;
   WHERE customer.country = "Canada" ;
   INTO ARRAY aMyArray

To specify a cursor as the destination

  • Use the INTO clause of the SELECT - SQL statement to specify a destination.

The following example shows an INTO clause for a cursor named mycursor:

SELECT * ;
   FROM tastrade!customer ;
   WHERE customer.country = "Canada" ;
   INTO CURSOR mycursor

If you create a table or an array, you can use it like any other table or array in Visual FoxPro. If you create a cursor, you can browse through its contents. The cursor is opened in the lowest available work area. You can access it by using the name you gave it in the SELECT - SQL statement.

The following two procedures describe two common ways to include query results stored in tables and cursors into an application.

See Also

Tasks

How to: Run Queries (Visual FoxPro)

How to: Populate Query Results in a Form Control

How to: Print Query Results in a Report or Label

Other Resources

Setting Query Output Destinations