Testing whether at table is joined

3361
4
01-19-2011 12:32 AM
MichaelStjernholm
New Contributor III
Hi,
Does anybody know how to see whether a feature layer or table view already contain a join, and if so how to get the name of the join table?

The problem arises from the fact that :
  - arcpy.AddField_management(...) returns an error if the feature class or table is joined and
  - arcpy.RemoveJoin_mangement() also returns an error if there no join !

There seems only to be tools like arcpy.AddJoin_management and arcpy.RemoveJoin_management

I miss:
a) arcpy.RemoveAllJoins_management

b) a TableView property hasJoin 

regards

Michael
Tags (2)
0 Kudos
4 Replies
ChrisSnyder
Regular Contributor III
I'd like to see some functionality related to testing/examining joins as well! I'm not a v10 pro though, so maybe there is more functionality exposed there than in v9.3...

It's probably a safe assumption that if a feature layer or table view has a "." in the field name, there is an active join. The table name of the table that is joined will of course have the same name as the part preceding the "." (mytable.fieldname). Not sure about the path though... Just curious but all the tools now have a "result object". Could perhaps one of the result objects from the RemoveJoin tool return the path of the join table??? Maybe one of the describe properties in v10?
0 Kudos
LoganPugh
Occasional Contributor III
That brings up an interesting point. How do you get the result object from a GP tool that is throwing an error? The result variable in result = gp.RemoveJoin_management("layerName", "fakeJoinName") never gets assigned because Python has to do something with the error it throws.

According to this geoprocessing blog post, you basically can't, unless running it as a GP service on ArcGIS Server.

As an aside, the table name used in the join will be in the error message if you use a nonexistent join name, so you could parse the error message for the table name.

Also I don't see anything new in 10 that helps with this. Maybe take a look at running ArcObjects under Python:
http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python
http://gis.stackexchange.com/questions/5017/python-comtypes-and-arcobjects-error-creating-approt-obj...
0 Kudos
MichaelStjernholm
New Contributor III
Hi Logan

I don't have a problem of getting my error message as I use ArcGIS10 and immideately get the error thrown in my processing window !

I was considering to solve the issue by grabbing the list of fields and check whether any of the fieldname.split(".) would result in 2 parts of which the first would be the Join table!

regards,

Michael
0 Kudos
FrédéricPRALLY
Esri Contributor

Hi,

Maybe try this GP tool: Get joined table properties using geoprocessing tool.

Have fun,

Fred

0 Kudos