0

I have a python (arcpy) script that extracts data from a database table, processes it, and inserts into a feature class. It works in my development environment but not in production. I recently removed a "IS NOT NULL" constraint from the database table so now the column is allowed to accept NULL values.

I verified the constraint was removed from this table. The column is nullable. And then I checked one more time... just to be sure

Where do I look next? How do I troubleshoot this issue?

Update 1 - NULL values are okay. I'm not trying to prevent NULL from hitting the database. If a value doesn't exist for a field, I want NULL.

Update 2 - The field in the database is set to allow NULL values. I verified it again. When viewing the FC properties in the catalog, within ArcMap, the field "Allow NULL values" is set to No. I'm guessing that's the problem. Why are the two out of sync and what do I do to fix it?

1

I always find it's easiest to first check if your value is not NULL before adding it to a table.

For example, say you have a value to be added to your table in variable Value. A simple if statement will do the trick. if will return True if the variable contains a value and is not NULL

Code:

*processing* = Value

if Value:
    *update table etc*
  • NULL is okay. There are plenty of NULL fields in the source data and I want that NULL passed to the destination database. – DenaliHardtail Feb 25 '15 at 20:30
  • Check the property of the destination field. It sounds as if it has been set to not allow null values. Are there plenty of NULL fields in the destination ? My guess is no. – jbchurchill Feb 25 '15 at 21:04
  • Are you potentially changing a value in the table to NULL, or are these always new rows? – Emil Brundage Feb 26 '15 at 16:09
0

I know this topic is a couple years old. However, I just ran into the same problem.

My solution was to only insert fields I had non None values for. The result is that the fields you don't set will be null or whatever their default values are.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.