Select to view content in your preferred language

Update data source of join table

1826
4
06-14-2013 04:20 AM
GIS_Administratorat_RWE
Occasional Contributor
Hi all,

I have compiled a script for migrating mxd's between a staging and productive environment. This script adapts the datasources and replaces qualifiers for label expressions and definition queries on layers.

Everything works fine except the update of the data source of joined tables / FC. The online help points out that using mxd.replaceWorkspaces() will also update joined tables:
"These methods work recursively through all layers and tables. This means that joined and related tables are also searched and updated (see "Known limitations" section below)." - bit it doesn't...

Does someone has got an idea?

Many thanks

Felix
Tags (2)
0 Kudos
4 Replies
MichaelVolz
Esteemed Contributor
Are you trying to update SDE datasources?  I ask because I have a script that updates SDE datasources for feature classes, but I am unable to update standalone tables because I cannot access the SDE connection properties for a standalone SDE table.

Is this a situation that you are encountering? 

Currently I just log the location of standalone tables and change them manually after the script has completed.  I can justify this because there a very few standalone SDE tables compared to SDE feature classes.  I'm hoping that ESRI exposes the connection properties for SDE standalone tables with the release of ArcMap v10.2.
0 Kudos
GIS_Administratorat_RWE
Occasional Contributor
Hi Michael,

yes I update SDE datasources. Standalone tables works fine with the following lines (hope that helps ;-)): 

for table in arcpy.mapping.ListTableViews(mxd, "", df):
            #print "      Replacing tabel wsp: " + table.name
            table.findAndReplaceWorkspacePath (<oldworkspace>, newworkspace, False)


My problem is onlly that joined tables (FC to FC or FX to standalone tables) won't get updated...

Kind regards

Felix
0 Kudos
MichaelVolz
Esteemed Contributor
Felix:

Question for you about your method of updating standalone SDE tables?

What if you had 1 table that had a SDE connection with user A and another table that had a SDE connection with user B? 

Would your script update both standalone tables to user A or user B depending upon what you used as your replace_workspace_path?

Or would your script just update the table for either user A or user B depending upon what you used for your find_workspace_path?
0 Kudos
GIS_Administratorat_RWE
Occasional Contributor
Hi Michael,

using an array of possible workspaces might solve your problem:

TheWSPReplaceArray=[[oldWSPUser1,newWSPUser1],[oldWSPUser2,newWSPUser2],...]
mxd=arcpy.mapping.MapDocument(TheMXD)

for item in TheWSPReplaceArray:
[INDENT]for table in arcpy.mapping.ListTableViews(mxd, "", df):[/INDENT]       
[INDENT][INDENT]table.findAndReplaceWorkspacePath (item[0], item[1], False)[/INDENT][/INDENT]
mxd.saveaCopy ...

Cheers

Felix
0 Kudos