FIX: COPY TO Incorrectly Copies All Fields to New Database

ID: Q115264

2.60 WINDOWS

The information in this article applies to:

SYMPTOMS

After you issue a SELECT-SQL command that selects specific fields from a table into a cursor, the COPY TO command will incorrectly copy ALL of the fields from the original table into the new table.

NOTE: This also occurs with a query produced by the Relational Query By Example (RQBE) window.

RESOLUTION

There are two workarounds you can use to get the desired results. Either workaround results in table TEMP1 correctly containing only the CNO and CITY fields.

Workaround 1

Send the results of your SELECT-SQL command to a table rather than a cursor. For example:

   ***Begin Code Example***
   SELECT cno,city from customer into TABLE temp1
   USE temp1
   BROWSE
   ***End Code Example***

Workaround 2

Use SET FIELDS to have only CNO and CITY available. For example:

   ***Begin Code Example***
   SELECT cno,city FROM customer INTO CURSOR temp
   SET FIELDS to cno,city
   COPY TO temp1
   USE temp1
   BROWSE
   ***End Code Example***

MORE INFORMATION

When the COPY TO command works correctly, it copies only the fields from the table in the current work area. The table in the current work area can be either a cursor or table.

However, in FoxPro 2.6 for Windows, if the table in the current work area is a cursor, the COPY TO command copies all the fields that are in the cursor's source table.

The following code example illustrates this behavior:

   ***Begin Code Example***
   SELECT cno,city from customer into CURSOR temp
   COPY to temp1
   USE temp1
   BROWSE
   ***End Code Example***

The TEMP1 table incorrectly contains all the fields that are in the CUSTOMER table.

Additional reference words: FoxWin 2.60 specific some few limit buglist2.60 fixlist2.60a KBCategory: KBSubcategory: FxtoolRqbe

Keywords          : kbcode FxtoolRqbe 
Version           : 2.60
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: May 22, 1998