English

Error: 5004: SpatialQuery.whereClause is not a valid SQL WHERE clause

Error Message


Note:
The ArcWeb Services product line has been retired. ESRI recommends that customers who wish to create Web applications or use services similar to those that were available in ArcWeb Services transition to the capabilities of ArcGIS Server and ArcGIS Online.


The following error message occurs even though the WHERE clause, which is very long, appears to be valid.

v2006.1:
"5004: not a valid SQL where clause or invalid fields used in the where clause."

v2006:
"5004: SpatialQuery.whereClause is not a valid SQL where clause Or Invalid fields used in the where clause."

v2:
"5004: ProximityOptions.whereClause is not a valid SQL where clause Or Invalid fields used in the where clause. "

Cause

The WHERE clause contains too many items. For example the IN statement can only hold 1000 values.

Code:
variable IN ( value1, value2, ... valueN)

Solution or Workaround

Split the IN clause into sets of 1,000-value IN clauses and put them together with the OR command:

Code:
variable IN (value1, value2, ... , value1000) OR variable IN (value1001, value1002, ... , value2000) OR variable IN (value2001, value2002, ... , value2345)

Note:
The ArcWeb Services product line has been retired. ESRI recommends that customers who wish to create Web applications or use services similar to those that were available in ArcWeb Services transition to the capabilities of ArcGIS Server and ArcGIS Online.