AnsweredAssumed Answered

Problems accessing GlobalID from an arcpy.da.SearchCursor

Question asked by mleahyesri-ca-esridist Employee on Nov 30, 2012
Latest reply on Apr 11, 2017 by bixb0012
Hello all,

I'm trying to use a search cursor to query GlobalID values from a feature class or table using the arcpy.da module's search cursor class.  It seems, however, that this is not supported.  I have tried the following:

>>> cur = arcpy.da.SearchCursor(featureclass,["globalid"])
>>> row = cur.next()
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: unsupported field type GLOBALID #11



>>> cur = arcpy.da.SearchCursor(featureclass,["globalid@"])
>>> row = cur.next()
Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: A column was specified that does not exist. 


I've tried all variations of letter cases (globalid, GlobalID, and GLOBALID), and it seems to make no difference.  I've tried requesting all fields for the feature class or table that I'm searching by providing ["*"] for the fields list, but the globalid field is not included in the resulting row data.

The following does work, however, if I use the non-'da' version of the SearchCursor class:

>>> cur = arcpy.SearchCursor(featureclass)
>>> row = cur.next()
>>> row.globalid
u'{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}'
>>> row.getValue("globalid")
u'{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}'


There doesn't seem to be any problem with a regular GUID type field...only with Global ID fields that have been added through the Add Global IDs geodatabse tool.  Is this a known limitation of the new data access module cursors, and/or is there some a more appropriate way to access global IDs through the arcpy.da module?  I don't really have a problem with using the other versions of the search cursors, but my interpretation from the documentation was that the cursors provided by the da module are more efficient...and this also makes me wonder if I should avoid querying Global IDs if there is a deliberate reason that they cannot be accessed with the new cursors.

Outcomes