I have two ESRI enterprise geodatabases on SQLServer: A and B. They are almost the same database (structure)
I have this code snippet in python to deleted several rows from versions:
def delete_project_features(edit_workspace, delete_tables, version, inspection_id):
sde_conn = arcpy.ArcSDESQLExecute(edit_workspace)
sde_conn.execute("EXEC sde.set_current_version '{0}';".format(version))
sde_conn.execute("EXEC sde.edit_version '{0}',1 WITH RESULT SETS NONE;".format(version))
for table in delete_tables:
inspectionId = inspection_id
feature_count = sde_conn.execute("SELECT COUNT(*) FROM {0}_evw WHERE INSPECTION_ID = '{1}';".format(table, inspectionId))
sde_conn.execute("DELETE FROM {0}_evw WHERE INSPECTION_ID = '{1}';".format(table, inspectionId))
try:
sde_conn.execute("EXEC sde.edit_version '{0}',2 WITH RESULT SETS NONE;".format(version))
except Exception as e:
if repr(e).find("error 266") > -1:
logEngine.log(_("Deleted all redundant features"), logger, SERVICE)
else:
mess = "Failed to delete features"
raise Exception(mess)
When I run it on Database A, the rows are deleted as expected, but in Database B the rows remain there.
I always get the error:
AttributeError: ArcSDESQLExecute: StreamExecute ArcSDE Extended error 266 [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.
despite the fact of the error, the rows are deleted on A
What setting could be different in the databases that prevents in B the successful result of the script execution?
Noted differences so far: Database A: Compatibility level 2016, Recovery model Simple, Collation SQL_Latin1_General_CP1_CI_AS.
Database B: Compatibility level 2012, Recovery model Full, Collation Latin1_General_CI_AS.
EDIT: The SQL commands run with any issue if they are run from SSMS.
The EGDB release for both is 10.7