fiendniu

How to make a variable query in SearchCursor?

Discussion created by fiendniu on Mar 19, 2012
Latest reply on Mar 25, 2012 by kimo
NearFIDlst = [33950, 7700, 4340]

I try to make a search query based on the values in the list NearFIDlst.


        f=0
        while f <len(NearFIDlst):


            Query = '"IN_FID"' +'='+ "'" + NearFIDlst[f] + "'"
            tempcur = arcpy.SearchCursor(NearTable, Query)
            tcur = tempcur.next()



the feedback keeps telling "TypeError: cannot concatenate 'str' and 'int' objects"

when I change the Query to:

Query = '"IN_FID"' + " = '" + str(NearFIDlst[f]) + "'"


it gives me "RuntimeError: ERROR 999999: Error executing function."

please help~~, Thanks lot

Outcomes