FIX: SQL with a UDF Causes "Invalid Subscript Reference"

Last reviewed: October 14, 1997
Article ID: Q105504
2.50    | 2.50
WINDOWS | MS-DOS kbprg kbfixlist kbbuglist kberrmsg

The information in this article applies to:

  • Microsoft FoxPro for Windows, version 2.5
  • Microsoft FoxPro for MS-DOS, version 2.5

SYMPTOMS

A Structured Query Language (SQL) SELECT command that uses a user-defined function (UDF) causes the following error:

   Invalid subscript reference.

STATUS

Microsoft has confirmed this to be a problem in FoxPro 2.5 for MS-DOS and FoxPro 2.5 for Windows. This problem was corrected in FoxPro 2.5a for MS-DOS and FoxPro 2.5a for Windows.

MORE INFORMATION

Steps to Reproduce Problem

Create and run a program with the following code:

   CREATE TABLE equip (equipment C(6))
   INSERT INTO equip (equipment) VALUES ;
      ('PHONE')

   CREATE TABLE timeitem (worksys C(10), jobnum C(9))
   INSERT INTO timeitem (worksys, jobnum) VALUES ;
      ('PAGER', '1')

   SELECT ti.worksys, ti.jobnum, eq.equipment ;
      FROM timeitem ti, equip eq ;
      INTO CURSOR testcur ;
      WHERE eq.equipment = whichval(ti.jobnum,ti.worksys)

   PROCEDURE whichval
   PARAMETERS jobnumval, worksysval
   IF EMPTY(jobnumval)
      RETURN worksysval
   ELSE
      RETURN "job"
   ENDIF

The following program error is generated:

   Invalid subscript reference.

The following message is the expected result:

   Selected 0 records in <x> seconds


Additional reference words: FoxDos FoxWin 2.50 buglist2.50 fixlist2.50a
errmsg err
msg
KBCategory: kbprg kbfixlist kbbuglist kberrmsg
KBSubcategory: FxprgSql
Solution Type : kbfix


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: October 14, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.