Microsoft KB Archive/103573

From BetaArchive Wiki

PRB: Simple SELECT to a Cursor Not Creating a Cursor

ID: Q103573

The information in this article applies to:

  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6, 2.6a
  • Microsoft FoxPro for Windows, versions 2.5x, 2.6, 2.6a

SYMPTOMS

When you are creating a cursor from a simple SELECT command and then selecting from the cursor into another cursor and DELETED is SET to OFF, FoxPro will generate the following error message:

   'cursor name' must be created with SELECT ... INTO TABLE

CAUSE

See the "More Information" section below for an illustration of the situation and an explanation of why this behavior occurs.

WORKAROUND

When DELETED is SET to ON, this error does not occur.

NOTE: If an index tag for DELETED() exists in the database, the error message will still be displayed.

STATUS

This behavior is by design. However, the documentation on the SELECT command states only that a SELECT command may be taken FROM an alias. The documentation does not mention that there are times when this operation will not work.

MORE INFORMATION

The following code illustrates this situation:

   SET DELETED OFF
   SET DEFAULT TO C:\FOXPROW\TUTORIAL
   SELECT * FROM Customer INTO CURSOR Cust1
   ?DBF()                                      && this should point to
                                               && CUSTOMER in TUTORIAL

   SELECT * FROM Cust1 INTO CURSOR Cust2       && this should generate
                                               && the error

   CLOSE ALL
   SET DELETED ON                              && this changes things
   SELECT * FROM Customer INTO CURSOR Cust1
   ?DBF()                                      && this should now point
                                               && to a .TMP file

   SELECT * FROM Cust1 INTO CURSOR Cust2       && this should work now
                                               && giving us Cust2

The SET DELETED ON command forces FoxPro to create a .TMP file rather than just point to the original file even if there are no fields in CUSTOMER that are marked for deletion. (This behavior would also occur if the SELECT command creating Cust1 were more restrictive.) The simple SELECT command in the above code fragment just causes FoxPro to use CUSTOMER again; since the SELECT * FROM Customer command represents the entire CUSTOMER table, FoxPro saves time by not really performing the SELECT command. Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 2.60a errmsg err msg KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxprgGeneral


Last Reviewed: June 27, 1995
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.