AnsweredAssumed Answered

CAST does not work in SearchCursor Queries?

Question asked by dougbrowning on Jul 17, 2018
Latest reply on Jul 18, 2018 by dougbrowning

I thought a found a slick way to compare on a number in a string field. 

 

CAST(SoilDepthLower AS INTEGER) < 70

 

This works in a ArcMap definition query just fine. 

 

But when I try to use it in a SearchCursor Query it says Invalid SQL Statement.

                    whereClause = "CAST(SoilDepthLower AS INTEGER) < 70"
                    keyField1 = arcpy.ListFields(tableLayer)[1].name
                    keyField2 = arcpy.ListFields(tableLayer)[2].name
                    fieldList = ["SoilDepthLower", keyField1, keyField2]
                    with arcpy.da.SearchCursor(tableLayer, fieldList, whereClause) as cursor:

 

I have tried smallint, double, etc - using both uppercase and lower case.

 

This help page says it is supported  http://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm

 

What is the issue?

 

Thanks

Outcomes