Formatting expression for selection on Joined table...

Discussion created by chuckrudd26 on May 18, 2012
I am writing a python script to join 2 tables (feature layer to feature layer), perform a select by attributes, and calculate the selected records.

The trouble I have been running into all day is an ExecuteError: ERROR 000358: Invalid Expression, when attempting to select the records to be updated.

With the tables joined I need to enter an qualified (table.field) value and have been using the following code:

AP_shp = r'C:\GIS\TEST\AddressPoints.shp'
APbase = (gp.ParseFieldName(os.path.basename(AP_shp)).split(",")[2]).strip()   #produces a string of the table name
JoinFC = toolDataPath + os.path.sep + "JoinFeatureClass.shp"
Joinbase = (gp.ParseFieldName(os.path.basename(JoinFC)).split(",")[2]).strip()   #produces a string of the table name

gp.MakeFeatureLayer_management(AP_shp, "AP_Layer", "", "", "")
gp.AddJoin_management("AP_Layer", "Join_ID", JoinFC, "Join_ID2", "KEEP_ALL")
qualFld = gp.addFieldDelimiters("AP_Layer", APbase + ".anyfield")
gp.SelectLayerByAttribute_management ("AP_Layer", "NEW_SELECTION", qualFld + " = " + 'L')

The expression prints as "Table.anyfield" = 'L'

Ive tried many less complicated methods of formatting the expression, but to no avail. Im at a loss and would appreciate any feedback!

Charles Rudder
GIS Technician/Analyst