Microsoft KB Archive/95294

= How to create a modifiable cursor by using the SELECT-SQL command in FoxPro =

Article ID: 95294

Article Last Modified on 3/18/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a

-



This article was previously published under Q95294



SUMMARY
When you issue a SELECT-SQL command that has the INTO CURSOR clause, a read-only cursor is created. This is true in Microsoft FoxPro for MS-DOS 2.x, in Microsoft Visual FoxPro for Windows 3.0, in FoxPro for Windows 5.0, and in FoxPro for Windows 6.0. To create a modifiable cursor, use one of the following workarounds.

Note Visual FoxPro 7.0 and later versions added the READWRITE clause to the SELECT-SQL command. This lets the SELECT-SQL command create a modifiable cursor.  Use the SELECT-SQL command with the INTO TABLE or INTO DBF clause. This command creates a new permanent table that can be deleted when it is no longer needed.  Use the following code (which uses the FoxPro 2.x CUSTOMER table): USE c:\foxpro2\tutorial\customer.dbf * USE the database that is being queried. =AFIELDS(struct_arr) * The array struct_arr contains the database structure. CREATE CURSOR temp FROM ARRAY struct_arr * temp has the structure of CUSTOMER.DBF. SELECT * FROM customer INTO ARRAY data_arr * data_arr contains the result of the query. SELECT temp APPEND FROM ARRAY data_arr * temp now contains the result of the query * and is not read-only. NOTE: This example works only if the SELECT-SQL command is from a single table and all fields are being selected. If this is not the case, you can modify struct_arr to reflect the structure of the fields being selected, or use the CREATE CURSOR command to create a temporary table with the appropriate structure. 

