Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Remove all default values on multiple feature classes

$
0
0
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:

Code:

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!

Viewing all articles
Browse latest Browse all 2485

Trending Articles