Creating Modifiable Cursor in FoxPro with SQL SELECT

Last reviewed: April 29, 1996
Article ID: Q95294
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

Issuing a SQL SELECT command with the INTO CURSOR clause creates a read-only cursor. To create a modifiable cursor, use one of the following workarounds:

  • Use the SQL SELECT command with the INTO TABLE or INTO DBF clause. This command creates a new permanent database 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 SQL SELECT command is from a
       single database 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


Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.x 2.50a
KBCategory: kbprg
KBSubcategory: FxprgSql


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.