Select to view content in your preferred language

Remove all default values on multiple feature classes

898
0
04-25-2014 12:17 PM
ChristopherBlinn1
Deactivated User
I would like to remove default values from all fields used by all feature classes in an SDE geodatabase. I do not see a geoprocess for removing the default value, only setting it. So I am trying to set it to "".

My approach is to use python to iterate through each feature dataset, then feature class, then field, and set the default value to "".

Here's what I have so far:

import arcpy
from arcpy import env

env.workspace = r"Database Connections\mysde.sde"

dsList = arcpy.ListDatasets("*", "Feature")
for dataset in dsList:
   fcList = arcpy.ListFeatureClasses("*","",dataset)
   for fc in fcList:          
      flds = arcpy.ListFields(fc,"*","String")
      for fld in flds:
         arcpy.AssignDefaultToField_management(fc, fld.name, "")

      flds = arcpy.ListFields(fc,"*","Double")
      for fld in flds:
         arcpy.AssignDefaultToField_management(fc, fld.name, None)

      flds = arcpy.ListFields(fc,"*","SmallInteger")
      for fld in flds:
         arcpy.AssignDefaultToField_management(fc, fld.name, None)

      flds = arcpy.ListFields(fc,"*","Integer")
      for fld in flds:
         arcpy.AssignDefaultToField_management(fc, fld.name, None)

      flds = arcpy.ListFields(fc,"*","Single")
      for fld in flds:
         arcpy.AssignDefaultToField_management(fc, fld.name, None)


When I run the script I get an error 000735 which means a default value is required.

How do I get around this (if at all possible)?

Thanks!
Tags (2)
0 Kudos
0 Replies