PRB: Query Wizard Cannot Set Relation If Tables Have Same Name

ID: Q114790

2.60    | 2.60
WINDOWS | MS-DOS kbtool kbprg kbprb

The information in this article applies to:

SYMPTOMS

The Query Wizard will be unable to set a relation between two tables if the filenames of the two tables are the same.

WORKAROUND

There are two possible workarounds:

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

1. In the Command window, issue the following command:

      USE <FoxPro_directory>\tutorial\customer

2. Issue the following command in the Command window where
   <other_directory> is any valid, existing directory name:

      COPY TO <other_directory>\customer

3. Start the Catalog Manager and create a new catalog.

4. Add <FOXPRO_DIRECTORY>\TUTORIAL\CUSTOMER to the catalog.

5. Add <OTHER_DIRECTORY>\CUSTOMER to the catalog.

6. Choose the Query tab and then choose New. Choose the Query Wizard.

7. Select either the SQL Query Wizard or the Updatable Query Wizard.

8. Add both versions of the CUSTOMER table to the query.

On screen 1A, note that all the fields in the child table are dimmed (grayed out), and you are unable to set a relation.

This behavior occurs because the Query Wizard depends on the filename matching the alias name for the table.

Under most circumstances, the filename and the alias name are the same. When two files with the same name are opened simultaneously in different work areas, FoxPro assigns an alias to the second file. This alias will change based on which work area is used to open the file. The alias name may be a single letter or the filename with an underscore and number added to the end.

All queries use the alias, not the filename, of the table to retrieve data.

The Query Wizard must create an alias name that will remain consistent regardless of the work area used to open the files. Internal functions are used to create an alias for each open .DBF file that exactly matches the filename. This is impossible to do when two files share exactly the same name.

REFERENCES

For more information about aliases, refer to the ALIAS() and DBF() functions in the FoxPro "Language Reference."

Additional reference words: FoxDos FoxWin 2.60 greyed unavailable KBCategory: kbtool kbprg kbprb KBSubcategory: FxtoolRqbe

Keywords          : FxtoolRqbe 
Version           : 2.60    | 2.60
Platform          : MS-DOS WINDOWS

Last Reviewed: May 1, 1996