INSERT Acts Like APPEND on Indexed Database

Last reviewed: June 27, 1995
Article ID: Q96339
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SUMMARY

In Microsoft FoxPro, the INSERT command is used to insert a record into the current database file immediately after the current record. However, when you are attempting to insert a record in a database that has an open index file, the INSERT command will work like the APPEND command and add the new record to the end of the database file. This behavior occurs even if the database is not ordered by any of the indexes in the open index file.

MORE INFORMATION

The INSERT command is included in FoxPro primarily for backward compatibility. The APPEND command should be used if possible and the order of the database can then be set using an index.

If the actual physical order of the data in the .DBF file is important, the SET INDEX TO command can be used without any additional arguments to close all open index files (except a structural .CDX file) in the current work area. The INSERT command can then be used to insert data in the desired order.

If the database has a structural .CDX index file, however, the INSERT command will always act like the APPEND command because a structural .CDX file is opened automatically when the database is opened. In order to use the INSERT command on a database with a structural .CDX file, all the index tags in the structural .CDX file must first be removed. They can then be recreated in a nonstructural .CDX file (with a different name from that of the .DBF file) which will not be automatically opened with the database.

REFERENCES

"Commands & Functions," version 2.0, INSERT command

"Language Reference," version 2.5, INSERT command


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbprg
KBSubcategory: FxprgGeneral


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: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.