AnsweredAssumed Answered

whereClause in SearchCursor issue in ArcMap 10.6

Question asked by Mohan.palleti on Oct 14, 2020
Latest reply on Oct 17, 2020 by Mohan.palleti

I am having a problem with whereClause in SearchCursor. Can anyone tell me what is the issue here?

 

When I use the first version without date everything works fine. When I add the date part. It fails with the error messages I pasted at the bottom:

 

>>

whereClause =   'STA_CODE = "' + code + '" AND FC IS NOT NULL AND FC <> 0'

 

whereClause =  'SAMP_DATE < "2020/12/31" AND STA_CODE = "' + code + '" AND FC IS NOT NULL AND FC <> 0'

 

recs = arcpy.SearchCursor(samples, whereClause, "", "", "SAMP_DATE D")

>>

 

>>>>>------

Failed script ScriptMP...

Traceback (most recent call last):
File "C:\Users\mpalleti\Documents\PMR\SamplingStatistics\test6E.py", line 47, in <module>
recs = arcpy.SearchCursor(samples, whereClause, "", "", "SAMP_DATE D")
File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\__init__.py", line 1186, in SearchCursor
return gp.searchCursor(dataset, where_clause, spatial_reference, fields, sort_fields)
File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\geoprocessing\_base.py", line 361, in searchCursor
self._gp.SearchCursor(*gp_fixargs(args, True)))
RuntimeError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.

Failed to execute (ScriptMP).

Outcomes