Solved! Go to Solution.
Thanks for looking at this!
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", "[parcelTv.parcel_key]", "VB", "")
## I get this:
## arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
## Failed to execute (CalculateField).
or for a Python calculation:
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", "!parcelTv.parcel_key!", "PYTHON_9.3", "")
## I get this:
## arcgisscripting.ExecuteError: ERROR 000539: Invalid field parcelTv.parcel_key
## Failed to execute (CalculateField).
...so I'm glad you are having success, but your recommendation isn't working though I suspect it's a data type thing. The field I'm calculating is a Long, and the source is an OBJECTID, and it didn't like me trying to cast to long like this
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", long("!parcelTv.parcel_key!"), "PYTHON_9.3", "")
...and with that I think I'll stick with the cursor method for the speed. I'd love to testing the speed difference but as I can't get the high level tool method to work I suppose that's not going to happen. I'd guess 100 times faster though. 😉
arcpy.CalculateField_management('calcLyr',"originallyrname.PARCEL_KEY", 'parcelTv.parcel_key')
Why doesn't this work?! I'm going nuts!
addrTbl = r'Database Connections\Connection to blah.sde\blah.dbo.addr'
parcelTbl = r'Database Connections\Connection to blah.sde\blah.dbo.parcel'
arcpy.MakeTableView_management(parcelTbl, 'parcelTv')
arcpy.MakeFeatureLayer_management('default.gdb\\bm_parcels_calc', 'calcLyr')
arcpy.AddJoin_management('calcLyr', "PARCEL_PIN", 'parcelTv',"parcel_id","KEEP_ALL")
# works to here.
arcpy.CalculateField_management('calcLyr',"PARCEL_KEY", 'parcelTv.parcel_key')
Show me how to fix it and I'll buy you lunch at next years UC!
I believe you forgot to qualify the calclyr PARCEL_KEY field with the underlying feature class name, especially since both the fc and table have the PARCEL_KEY field.
So I believe it should be (double check the single/double quotes also):
arcpy.CalculateField_management('calcLyr','bm_parcels_calc.PARCEL_KEY', 'parcelTv.parcel_key')
import arcpy arcpy.env.workspace = r'E:\gis\engineering\20130806_SLCO_parcel_process' parcelTbl = r'Database Connections\Connection to slcisql.sde\GEODB.dbo.parcel' d = {} flds = ['parcel_id', 'PARCEL_KEY', 'ADDR_SERIAL', 'UNIT', 'BLOCK', 'SUBDIVISION', 'LAND_USE_CODE'] with arcpy.da.SearchCursor(parcelTbl, flds) as c: for r in c: d[r[0]] = (r[1], r[2], r[3], r[4], r[5], r[6]) print len(d) print d['07352010040000'] flds = ['PARCEL_PIN', 'PARCEL_KEY', 'ADDR_SERIAL', 'UNIT', 'BLOCK', 'SUBDIVISION', 'LAND_USE_CODE'] with arcpy.da.UpdateCursor('default.gdb\\bm_parcels_calc', flds) as cc: for rr in cc: if d.has_key(rr[0]): rr[1] = d[rr[0]][0] rr[2] = d[rr[0]][1] rr[3] = d[rr[0]][2] rr[4] = d[rr[0]][3] rr[5] = d[rr[0]][4] rr[6] = d[rr[0]][5] cc.updateRow(rr) else: pass
Thanks for looking at this!
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", "[parcelTv.parcel_key]", "VB", "")
## I get this:
## arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
## Failed to execute (CalculateField).
or for a Python calculation:
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", "!parcelTv.parcel_key!", "PYTHON_9.3", "")
## I get this:
## arcgisscripting.ExecuteError: ERROR 000539: Invalid field parcelTv.parcel_key
## Failed to execute (CalculateField).
...so I'm glad you are having success, but your recommendation isn't working though I suspect it's a data type thing. The field I'm calculating is a Long, and the source is an OBJECTID, and it didn't like me trying to cast to long like this
arcpy.CalculateField_management('calcLyr', "bm_parcels_calc.PARCEL_KEY", long("!parcelTv.parcel_key!"), "PYTHON_9.3", "")
...and with that I think I'll stick with the cursor method for the speed. I'd love to testing the speed difference but as I can't get the high level tool method to work I suppose that's not going to happen. I'd guess 100 times faster though. 😉
ok, I never use model builder but went ahead on your recommendation and here's how it looks after export!
arcpy.CalculateField_management('bm_parcels_calc', "bm_parcels_calc.PARCEL_KEY", "!myDB.\"myNT\\myUsername\".%parcel.parcel_key!", "PYTHON_9.3", "")
"!myDB.\"myNT\\myUsername\".%parcel.parcel_key!" seriously!!! I wouldn't have guessed!