How to create a modifiable cursor by using the SELECT-SQL command in FoxPro (95294)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
- Microsoft FoxPro for MS-DOS 2.0
- Microsoft FoxPro for MS-DOS 2.5
- Microsoft FoxPro for MS-DOS 2.5a
- Microsoft FoxPro for Windows 2.5
- Microsoft FoxPro for Windows 2.5a
This article was previously published under Q95294 SUMMARYWhen 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.
REFERENCES
"Commands & Functions," version 2.0, pages C3-701 to C3-705
Modification Type: | Major | Last Reviewed: | 3/18/2005 |
---|
Keywords: | KB95294 |
---|
|