PRB: Using SELECT-SQL INTO TABLE w/ Same Filename Causes Error

ID: Q118780

2.00 2.5x 2.60 | 2.5x 2.60

MS-DOS         | WINDOWS
  kbprb kbdocerr

The information in this article applies to:

SYMPTOMS

The documentation for the SELECT-SQL INTO DBF <table> | TABLE <table> command (page C3-704 in the "Commands & Functions" manual for FoxPro version 2.0 and page L3-866 in the "Language Reference" manual for FoxPro versions 2.5x and 2.6) incorrectly states that by specifying the name of a table/.DBF that is already open, FoxPro closes the file and reopens the table without giving a warning if SET SAFETY is OFF. Instead, using the same filename in the Save As dialog box causes the error message "File is in use."

CAUSE

When a table is created with a SELECT-SQL statement, the original table is not closed as specified in the documentation when the same table name is used. FoxPro uses QUERY.DBF as the default table name when Table/DBF is selected in the Output list box. If the table name used for output is the same as the filename specified in the Tables dialog box, a syntax error is generated. In the following example, the CUSTOMER table is selected, Table/DBF is selected in the Output list box, and the default value is used in the Save As dialog box. Using these values, the following SELECT statement is generated, as illustrated by the See SQL button in the Relational Query by Example (RQBE) window.

   SELECT *;
     FROM Customer;
     INTO TABLE <path>\query.dbf

After you run the query, if you then select Table/DBF in the Output list box and then enter the same table name in the Save As dialog box (in this case, QUERY.DBF), the "File is in Use" error occurs.

RESOLUTION

To avoid this problem, use a different name for the file instead of the same table/.DBF name used in the Save As dialog box. Because a different filename is used in the INTO TABLE clause of the SELECT statement, the error will not occur.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 Alias errmsg err msg docerr

KBCategory:   kbprb kbdocerr
KBSubcategory: FxtoolRqbe
Keywords          : kberrmsg FxtoolRqbe 
Version           : 2.00 2.5x 2.60 | 2.5x 2.60
Platform          : MS-DOS WINDOWS

Last Reviewed: May 22, 1998