Microsoft KB Archive/103031

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 08:24, 20 July 2020 by X010 (talk | contribs) (Text replacement - """ to """)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Article ID: 103031

Article Last Modified on 3/10/2005



APPLIES TO

  • Microsoft FoxPro 2.5b
  • Microsoft FoxPro 2.5a
  • Microsoft FoxPro 2.0
  • Microsoft FoxPro 2.5b for MS-DOS
  • Microsoft FoxPro 2.5a
  • Microsoft Visual FoxPro 3.0 Standard Edition
  • Microsoft Visual FoxPro 3.0b Standard Edition
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition
  • Microsoft Visual FoxPro 7.0 Professional Edition
  • Microsoft Visual FoxPro 8.0 Professional Edition



This article was previously published under Q103031

SYMPTOMS

The "SQL expression too complex" error message appears if you have used 25 or more values in the IN clause of the SELECT-SQL command.

CAUSE

The maximum number of values is 24 that you can include in the IN clause.

Note Microsoft Visual FoxPro 9.0 removes the limit of 24 values in the IN (Value_Set) clause for the WHERE clause. However, the number of values remains subject to the setting of "SYS(3055) – FOR and WHERE Clause Complexity."

RESOLUTION

See the "More Information" section for an example of the problem and a workaround.

MORE INFORMATION

Steps to Reproduce Problem

FoxPro 2.0, 2.5, or 2.6

  1. Use the Customer.dbf table in the Tutorial directory.
  2. Issue the following SELECT-SQL command:

    Select * from customer where cno in;
    ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15',;
    '16','17','18','19','20','21','22','23','24','25')
                        

    The "SQL expression too complex" error message appears.

Visual FoxPro 3.0, 5.0, 6.0

  1. Use the Customer.dbf table. In Visual FoxPro 3.0 and 5.0, Customer.dbf is located in the Samples\Data folder. In Visual FoxPro 6.0 and later, use this command:

    USE HOME(2)+"data\customer.dbf"
                        
  2. Issue the following SELECT-SQL command:

    Select * from customer where cust_id in;
    ('ALFKI','ANATR','ANTON','AROUT','BERGS','BLAUS','BLONP','BOLID','BONAP','BOTTM',;
       'BSBEV','CACTU','CENTC','CHOPS','COMMI','CONSH','DRACD','DUMON','EASTC','ERNSH',;
       'FAMIA','FISSA','FOLIG','FOLKO','FRANK')

    The "SQL expression too complex" error message appears.

Workaround

  1. In FoxPro 2.x, create a temporary table with one field in it called CNO. In Visual FoxPro, name the field Cust_id. The Temp table should contain the values in the CNO or Cust_id field that you want to find in the Customer table.
  2. Issue one of the following SELECT-SQL commands depending on your version of FoxPro:

    ** For FoxPro 2.x use this line
    Select * from customer where cno in (select cno from temp)
    
    ** For Visual FoxPro, use this line
    Select * from customer where cust_id in (select cust_id from temp)
                        



Additional query words: FoxDos FoxWin

Keywords: KB103031