Select to view content in your preferred language

arcpy.RemoveJoin_management error (bug?)

2872
11
09-07-2012 11:28 AM
MichaelPorter1
Occasional Contributor
Using ArcMap 10.1

When I run the following in the Python window:

arcpy.RemoveJoin_management("POD", "")

I get this error:

Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\management.py", line 5402, in RemoveJoin     raise e ExecuteError: ERROR 000582: Error occurred during execution.

Tried everything I could think of: replacing first argument with layer reference, removing second argument, setting secong argument ... Weird thing is when I run the same code in ModelBuilder it works.  I export the python from ModelBuilder and it is the exact same as above.

Any thoughts?

Thanks
0 Kudos
11 Replies
curtvprice
MVP Esteemed Contributor
Is this a raster layer? If so, this is a bug I have logged, reportedly fixed in 10.1 SP 1.

[#NIM066368  Remove Join tool fails when the input is a raster with a joined field.]
http://support.esri.com/en/bugs/nimbus/role/beta10_1/TklNMDY2MzY4
0 Kudos
MichaelPorter1
Occasional Contributor
nope.  Feature Layer.  Will try SP1 though.

Thanks
0 Kudos
ChrisSnyder
Honored Contributor
You don't appear to be naming the join table you want to remove (which is required, and is the name of the join table).
For example:

fc = r"C:\temp.gdb\my_mc"
lut = r"C:\temp.gdb\my_lut"
arcpy.MakeFeatureLayer_managment(fc, "mickeymouse")
arcpy.AddJoin_mangement("mickeymouse", "ID", lut, "ID")
arcpy.RemoveJoin_management("mickeymouse", "my_lut")
0 Kudos
MichaelPorter1
Occasional Contributor
Thanks for your response

I tried that and it did not work.

Also, according to the help documentation {join_name} is optional
0 Kudos
by Anonymous User
Not applicable
Did you use the JoinField function rather than the AddField by accident?  If you used  arcpy.JoinField_management you cannot remove the join because this makes a permanent join to the attribute table, whereas the arcpy.AddJoin_management will make a temporary join that can be removed.  This is the only reason I can think of as to why you cannot remove the join.
0 Kudos
ChrisSnyder
Honored Contributor
The Help topic is wrong in that regard. I cannot think of an instance when the join name would be an optional parameter. In fact the Help topic is pretty clear about the proper naming convention of the join name: http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000066000000.

Here is some of my own v10.1 Python code that uses the RemoveJoin tool:

#Process: Populates the O_RB_DIST, O_RB_OID, and O_RB_WTY fields
oesfRipBuffFC = root + "\\layer_prep\\oesf_rip_buff.gdb\\oesf_rip_buff"
arcpy.MakeFeatureLayer_management(indxTileFC, indxTileFL, "FID_oesf_rip_buff > -1")
if int(arcpy.GetCount_management(indxTileFL).getOutput(0)) > 0:
    arcpy.AddJoin_management(indxTileFL, "FID_oesf_rip_buff", oesfRipBuffFC, "OBJECTID", "KEEP_COMMON")
    arcpy.CalculateField_management(indxTileFL, "O_RB_OID", "[oesf_rip_buff.LDO_OID]", "VB")
    arcpy.CalculateField_management(indxTileFL, "O_RB_DIST", "[oesf_rip_buff.DISTANCE]", "VB")
    arcpy.CalculateField_management(indxTileFL, "O_RB_WTY", "[oesf_rip_buff.SL_WTRTY_CD]", "VB")
    arcpy.RemoveJoin_management(indxTileFL, "oesf_rip_buff")
0 Kudos
ChrisSnyder
Honored Contributor
Forgot to ask: Is there something unusual about your parent table or look up table? For example, is your look up table a GRID .vat, an ODBC table, Excel table, etc.?

Posting more of your code would be helpful (use the # code tag button).
0 Kudos
SteveSalas
Frequent Contributor
I am still at base ArcGIS 10.1 (no sp1)... RemoveJoin in my script worked fine at 10.0, fails in 10.1.  The layer being joined to is a ArcSDE feature class in Oracle.  The joined table is also from Oracle ArcSDE 10.0

At 10.0, the "join_name" parameter was in the format "owner.table" - no problems
At 10.1 "owner.table" format fails, the error message indicates that the parameter should be just "table" - which matches the options in the drop-down if I try to use RemoveJoin tool in ArcToolbox.  In either case, script or Toolbox tool, the RemoveJoin still fails with the format "table".  The Toolbox tool considered all inputs valid... but it fails with a 999999... error when run.  The only way I can make this tool work is by leaving the "join_name" parameter blank which removes all joins, and appears to be my workaround for now.

Nothing seems to match this in the SP1 resolved issues list.
0 Kudos
GlennCondon
Deactivated User
I have had a very interesting episode with this operation as well.  For the record I'm working with 10.0 and have not been able to get this to work in an ArcTool script. The only way I could get this to work was by choosing the parameter options from the interactive Python Window.  The most inexplicable thing was, if I manually typed in the correct parameters I get a syntax error.  If I take the drop-down list choices I'm good.  This has certainly got to be a bug that needs to be addressed.  See screen shot from Python Window with highlighted Parsing Error and successful execution of the command in last line.[ATTACH=CONFIG]20457[/ATTACH]
0 Kudos