Select to view content in your preferred language

Cannot insert the value NULL into column - yet column value is not null

298
1
04-03-2024 05:58 AM
Labels (1)
mikAMD
by
Occasional Contributor III

I'm using the api python function edit_features() but I believe this is a more general question about the structure of my data and how to use the REST API. I keep getting the error "Cannot insert the value NULL into column 'inspecteur_man_id'" even though I'm sending a value for this field.

I have this flat table inside a feature service on AGOL, it contains a couple of fields, including:

{
  "name": "objectid",
  "type": "esriFieldTypeOID",
  "alias": "objectid",
  "sqlType": "sqlTypeOther",
  "nullable": false,
  "editable": false,
  "domain": null,
  "defaultValue": null
}, {
  "name": "inspecteur_man_id",
  "type": "esriFieldTypeInteger",
  "alias": "inspecteur_man_id",
  "sqlType": "sqlTypeOther",
  "nullable": false,
  "editable": false,
  "domain": null,
  "defaultValue": null
}

and indexes on theses fields are as follows:

{
  "name": "idxInspecteurs_manInspecteur_man_id",
  "fields": "inspecteur_man_id",
  "isAscending": true,
  "isUnique": true,
  "description": "index on inspecteur_man_id",
  "indexType": "Attribute"
}, {
  "name": "PK__gestion___5242E6323170AFE1",
  "fields": "objectid",
  "isAscending": true,
  "isUnique": true,
  "description": "clustered, unique, primary key",
  "indexType": "Attribute"
}

 

I'm trying to add features (one at the moment) to the table with the edit_features() function (I'm currently having problem with append(), on an ESRI support case about it).

Here is my code:

adds = [{'attributes': {'objectid': 63, 'inspecteur_man_id': 23, 'fielda': 'somevalue', 'fieldb': 'somevalue'}}]

# table variable is retrieved previously
# type(table) 
# <class 'arcgis.features.layer.Table'>

resultsEdit = table.edit_features(
        adds=adds,
        rollback_on_failure=True,
    )

 

However, the server seems to think that I'm not sending a value for the field "inspecteur_man_id" because this is what I keep getting back:

{"addResults":
    [
        {
            'objectId': 63, 
            'uniqueId': 63, 
            'globalId': '1518DB05-8810-472A-809F-1B35B82F4256', 
            'success': False, 
            'error': {
                'code': 1000,
                'description': 'Cannot insert the value NULL into column "inspecteur_man_id", table "db_16513.user_16513.gestion_actifs_INSPECTEURS_MAN3"; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated.'
            }
        }
    ], 
    'updateResults': [], 
    'deleteResults': []
}

 

I also tried sending the adds without and objectid and without the inspecteur_man_id fields. I have all the rights to edit, I'm the owner and creator of the service.

My next troubleshooting step will be to create another field but change the index to isAscending to False, possibly isUnique to False and also change the field nullable to True and editable to True... Even though from what I understand this should not be causing this problem.

Anybody had a similar problem recently or thoughts on what is wrong?

Thanks!

0 Kudos
1 Reply
mikAMD
by
Occasional Contributor III

What was successful was creating a new field and setting editable to True. However, I believe I was able to edit records in the past in other tables even though if this parameter was set to False. I'm now starting to second guess my workflow, maybe I'll have to change all the fields that are set to False ...

I'll leave the thread opened in case something can confirm this.

0 Kudos