Skip to main content
2 of 2
removed thanks
Vince
  • 20.3k
  • 16
  • 48
  • 65

Can't get the where clause in Select layer by attribute working!

I am trying to develop a script that searches for a particular ID in a user selected field. To this end I have used the select layer by attributes tool to search for a derived number in a field specified by the user.I cannot, however, after numerous attempts, get the where clause right. I have posted my latest attempt below:

import arcpy
from arcpy import env

work_space = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRNb\\EDRN_holding.gdb"

env.workspace = work_space

arcpy.env.overwriteOutput = True

selected_li = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRN_holding.gdb\\EDRN7\\EDRN_LINK"
OB_ID = "OBJECTID_1"

rows = arcpy.SearchCursor(selected_li)
for row in rows:
    id_LCC = row.getValue(OB_ID)
    id_TNDE = row.getValue("TO_DRNNODE")
    if id_TNDE == " " or id_TNDE == None:
        arcpy.MakeFeatureLayer_management(selected_li, "feature_layer10") 
        arcpy.SelectLayerByAttribute_management ("feature_layer10", "NEW_SELECTION", '"' + str(OB_ID) + '" =' + "'" + str(id_LCC) + "'")

So, if anyone has any ideas please do let me know.

Geord359
  • 313
  • 6
  • 20