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.
Solved! Go to Solution.
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.
If you want to save the globalids from the previous dataset, try setting the preserve global id setting in arcpy env.
# Set the preserveGlobalIds environment to True
arcpy.env.preserveGlobalIds = True
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.
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.
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.
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.
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.
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)