Change Version (Data Management)

License Level:BasicStandardAdvanced

Summary

Each input feature layer or table view will have its workspace modified to connect to the requested version.

Usage

Syntax

ChangeVersion_management (in_features, version_type, {version_name}, {date})
ParameterExplanationData Type
in_features

The feature layer or table view to connect to using the specified version.

Feature Layer; Table View
version_type

The type of version to change to.

  • TRANSACTIONALConnect to a defined state of the database.
  • HISTORICALConnect to a version representing a defined moment in time, often specified by a time or Historical Marker.
String
version_name
(Optional)

Name of the version to change to. Optional if using historical versions.

String
date
(Optional)

Date of the historical version to change to.

Date

Code Sample

ChangeVersion Example (Python Window)

The following Python window script demonstrates how to use the ChangeVersion function in immediate mode.

import arcpy
from arcpy import env
env.workspace = r'c:\Connections\toolbox.sde'
arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.street','RedlandsStreets')
arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.streams','RedlandsStreams')
arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'),
                                  'StreamsNearStreets','','','')
arcpy.ChangeVersion_management('RedlandsStreets','TRANSACTIONAL', 'TOOLBOX.proposedStreets2k9','')
arcpy.MakeFeatureLayer_management(arcpy.SelectLayerByLocation_management("RedlandsStreams","WITHIN_A_DISTANCE","RedlandsStreets","100 Meters","NEW_SELECTION",'#'),
                                  'NewStreamsNearStreets','','','')
ChangeVersion example (Stand-alone script)

Use the ChangeVersion tool in a typical versioned analysis workflow.

# Name: ChangeVersion.py
# Description: Use the ChangeVersion tool in a typical versioned analysis workflow.
#              Quick check of additional streams within a pre-determined distance
#              of new proposed street development.
# Author: ESRI

# Import system modules 
import arcpy
from arcpy import env
import sys, os

# Set environments
env.workspace = sys.path[0] + os.sep + "toolbox.sde"

# Create the layers
arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.street','RedlandsStreets')
arcpy.MakeFeatureLayer_management(r'TOOLBOX.Redlands\TOOLBOX.streams','RedlandsStreams')

# Perform analysis on the Default version to determine
# current number of streams within 100 meters of streets.
selection1 = arcpy.SelectLayerByLocation_management("RedlandsStreams",
                                                    "WITHIN_A_DISTANCE",
                                                    "RedlandsStreets",
                                                    "100 Meters",
                                                    "NEW_SELECTION",
                                                    '#')
arcpy.MakeFeatureLayer_management(selection1,'StreamsNearStreets','','','')
print "Streams within 100 Meters of current streets: " + \
      str(arcpy.GetCount_management("StreamsNearStreets"))

# Change to the development version
arcpy.ChangeVersion_management('RedlandsStreets',
                               'TRANSACTIONAL',
                               'TOOLBOX.proposedStreets2k9',
                               '')

# Perform the same analysis on the development version to see the effect of the proposed changes.
selection2 = arcpy.SelectLayerByLocation_management("RedlandsStreams",
                                                   "WITHIN_A_DISTANCE",
                                                   "RedlandsStreets",
                                                   "100 Meters",
                                                   "NEW_SELECTION",
                                                   '#')
arcpy.MakeFeatureLayer_management(selection2,'NewStreamsNearStreets','','','')
print "Streams projected to be within 100 Meters of streets after proposed street additions: " + \
      str(arcpy.GetCount_management("NewStreamsNearStreets"))

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015