maho

arcpy.da.Searchcursor sql_clause

Discussion created by maho on Feb 12, 2012
Latest reply on Sep 26, 2013 by oscarjavier04
Hi,

Can someone shed a bit of light on the sql_clause parameter on arcpy.da.SearchCursor?

The help states that the pre-fix supports None, DISTINCT and TOP and the post-fix supports None, ORDER_BY and GROUP_BY, but I'm not sure how to formulate it corrcetly.

For example:

layer = "c:/temp/myGdb.gdb/myFeatureClass"
dsc = arcpy.Describe(layer)
OIDFieldName = dsc.OIDFieldName
delimitedFieldName = arcpy.AddFieldDelimiters(layer, OIDFieldName)
sWhereClause = delimitedFieldName + " < 100"
sql_clause = (None,'ORDER BY OBJECTID DESC')

rows = arcpy.da.SearchCursor(layer,("SHAPE@","OID@"),sWhereClause,None,False,sql_clause)
rows.reset()  # Throws a 'not callable function' error

Outcomes