Select to view content in your preferred language

Insert cursor fails when data includes a GlobalID field

1369
7
Jump to solution
08-10-2022 06:16 PM
CarlBeyerhelm
Frequent Contributor

I'm using an arcpy insert cursor in ArcMap 7.1 to add features to an in_memory feature class, and this works fine except when the source feature class includes an indexed GlobalID field.  The error I receive is "SystemError: error return without exception set".

If I use FeatureClassToFeatureClass to convert the source FC to a new feature class, and drop the GlobalID field, the insert works fine again.

The in_memory guidance warns that in_memory "does not support extended geodatabase elements such as subtypes, domains, representations, topologies, geometric networks, and network datasetsabout", but I don't see anything about GlobalIDs being an issue.  Any insights would be appreciated.

0 Kudos
1 Solution

Accepted Solutions
forestknutsen1
MVP Regular Contributor

My, guess is this. Because they GlobalID field is system managed it will not let you insert a value into it. It would be like you trying to create your own object ID's. It is just not something you can do. So, remove the field from your insert or create a target field of type GUID. 

View solution in original post

7 Replies
by Anonymous User
Not applicable

If you want to save the globalids from the previous dataset, try setting the preserve global id setting in arcpy env.

preserve-globalids 

# Set the preserveGlobalIds environment to True
arcpy.env.preserveGlobalIds = True

 

BlakeTerhune
MVP Regular Contributor

Just yesterday I had to append data from our test environment to production and had to redo all the relationships because the GlobalID values were changed. I had no idea this setting existed.

0 Kudos
forestknutsen1
MVP Regular Contributor

So, GlobalIDs are managed by the system so you should not be trying to insert them. If you want to move them around you can use @Anonymous User method to preserve global ID's. Or if you like you can add a new field of data type GUID and then insert ID's in there. Of, course if you do so the new GUID field will no longer be managed by the system - it will be on you to keep it updated.

0 Kudos
CarlBeyerhelm
Frequent Contributor

Thanks for the replies, but I think my issue has been misinterpreted.  Apologies if it was unclear.

In this case, I'm not concerned with the transfer, or the values, of GlobalIDs.

Rather, I'm trying to understand why my insert cursor does not work when the inserted record (I'm inserting an entire record, not just a value) contains a GlobalID field and the insert cursor's target is an in_memory feature class.  The cursor works as expected if no GlobalID field is present.

0 Kudos
forestknutsen1
MVP Regular Contributor

My, guess is this. Because they GlobalID field is system managed it will not let you insert a value into it. It would be like you trying to create your own object ID's. It is just not something you can do. So, remove the field from your insert or create a target field of type GUID. 

by Anonymous User
Not applicable

It will throw an error for the entire record because the process is an all or nothing transaction.

I can't tell what fields are available in the in_memory fc, or what fields the cursor has, or what fields are being mapped/ assigned. Generally, you can leave the GlobalID field index (i.e. row[20]) empty and it will create its own value on insertion. Maybe sharing how you have the cursor set up would help explain it better.

0 Kudos
CarlBeyerhelm
Frequent Contributor

OK, that makes sense forestknutsen1.  Thanks.

JeffK - Fields in the in_memory fc are cloned from the source fc via a field list, so I just modified construction of the field list to omit GlobalID, if it is present, as illustrated below.

fieldList = []
fields = arcpy.ListFields(inSec)
for field in fields:
  if field.type != "GlobalID":
    fieldList.append(field.name)

0 Kudos