Domains visible in ArcGIS Pro but not ArcMap

441
1
07-11-2022 12:55 PM
Labels (3)
AaronSchuck
New Contributor III

Some users have reported an error when attempting to copy and paste feature classes from an enterprise geodatabase (See Image #1).

After looking at the domains in the geodatabase, we see that the correct number of domains is present in ArcGIS Pro, but absent in Arc Catalog which you can see in Image #2.

The same code snippet was run in ArcGIS Pro & Arc Catalog on the same geodatabase with different results.

gdb = r'PathToGDB'
arcpy.env.workspace = gdb
print len(arcpy.da.ListDomains())

0 Kudos
1 Reply
AaronSchuck
New Contributor III

After working with an ESRI representative, we found there were orphan domains in the geodatabase.

The procedure below details how to generate a list of orphaned domains for a geodatabase. To eliminate uncertainty, it’s best to remove all domains from every feature class and table and then delete all domains using arcatalog/arcpy. After this is done, we check in SQL again for any remaining domains and delete them to ensure there is nothing left.


1.) Select all domains currently in geodatabase using SQL:

SELECT *
FROM [sde].[GDB_ITEMS]
Where Type = '8C368B12-A12E-4C7E-9638-C9C64E69E98F'


2.) Compare the SQL domains with the arcpy domains: 

gdb = r'YourGeodatabasePath'
arcpy.env.workspace = gdb
domains = arcpy.da.ListDomains()
sqlDomains = ('List of domains generated in SQL')
stringDomains = []

for domain in domains:
    stringDomains.append(str(domain.name))

for domain in sqlDomains:
    if domain not in stringDomains:
        print domain

 

To remove and delete all domains in arcpy/arccatalog:    

## Removing & deleting all domains in a gdb
import arcpy, traceback
gdb = r'YourGeodatabasePath'
arcpy.env.workspace = gdb
desc = arcpy.Describe(gdb)

for child in desc.children:
   if child.dataType in ['Table','FeatureClass']:
       for field in child.fields:
           if field.domain:
               item = child.name
               try:
                   arcpy.RemoveDomainFromField_management(item, field.name)
               except arcpy.ExecuteError as e:
                   print("*** Remove Domain From Field *** arcpy.ExecuteError ***")
                   print(e.message)
                   print(traceback.format_exc())


domains = arcpy.da.ListDomains(gdb)
for domain in domains:
    arcpy.DeleteDomain_management(gdb, domain.name)

 

 

0 Kudos