PRB: SQL SELECT Causes ICE or "Invalid Function Argument..."

Last reviewed: April 30, 1996
Article ID: Q109583
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Macintosh, version 2.5b

SYMPTOMS

The following SQL SELECT statement causes an "Internal Consistency Error" in FoxPro for Windows and FoxPro for MS-DOS. In FoxPro for Macintosh, the SELECT statement causes the error message "Invalid function argument value, type, or count."

This code creates the tables on which to perform the SELECT statement:

   CREATE TABLE customer ;
      ( cno C(5), company C(35), contact C(20), ;
      address C(30), city C(15), state C(2), zip C(5), ;
      phone C(12), ono C(1), ytdpurch N(8,2), lat N(7,4), ;
      long N(8,4) )

   CREATE TABLE invoices ;
      ( ino N(4), cno C(5), idate D, itotal N(8), ;
      salesman C(3) )

   CREATE TABLE detail ;
      ( ino N(6), cno C(5), LINE N(4), qty N(4), ;
      pno C(5), price N(8), ltotal N(8) )

   INSERT INTO customer (cno, company, contact, address, ;
      city, state, zip, ;
      phone, ono, ytdpurch, lat, long) ;
      VALUES ('a123', '1st Company', 'No Name', 'One Microsoft Way', ;
      'Redmond', 'WA', '98052', '1206123456', '1', ;
      1000.99, 100.999, 100.999)


   INSERT INTO invoices (ino, cno, idate, itotal, salesman) ;
      VALUES (9999, 'A123', {09/01/93}, 1000.99, 'Bob')

   INSERT INTO detail (ino, LINE, qty, pno, price, ltotal) ;
      VALUES (9999, 1234, 2,'B6722', 27.99, 57.98)

This is the code that produces the error:

   SELECT IIF(customer.cno = invoices.cno,SPACE(8),;
      one(detail.ino, company, lat)) AS test;
      FROM customer,invoices,detail;
      INTO CURSOR two;
      WHERE customer.cno = invoices.cno;
      ORDER BY 1

   PROCEDURE one
   PARAMETERS A,B,C
   RETURN SPACE(8)

RESOLUTION

To work around this problem, preface the field names with the table name in the IIF() statement. For example:

   SELECT IIF(customer.cno = invoices.cno,SPACE(8),;
      one(detail.ino, customer.company, customer.lat)) AS test;
      FROM customer,invoices,detail;
      INTO CURSOR two;
      WHERE customer.cno = invoices.cno;
      ORDER BY 1

   PROCEDURE one
   PARAMETERS A,B,C
   RETURN SPACE(8)


Additional reference words: VFoxWin 3.00 FoxMac FoxDos FoxWin 2.50 2.50a
2.50b iif ice
crash
errmsg
err msg
KBCategory: kbprg kberrmsg kbprb
KBSubcategory: FxprgSql


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: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.