English

Bug: The DBMS attribute contains a default value that does not set

Description

If a database management system (DBMS) attribute contains a default value it does not set because the geodatabase sets the attribute to NULL when performing an insert.

Working with non-versioned classes, a default value for a table's attribute may be defined. When an application inserts a row into the table and the attribute is not referenced in the INSERT statement, the database automatically sets the value of the attribute to the default value.

Since the geodatabase is an object-oriented application, all values are initialized when objects (rows) are created. Attributes that are nullable are set as NULL. Attributes that are not nullable receive initial values so as not to violate the NOT NULL constraint when the row is inserted into the table.

Note:
Varchar values are defined as an empty string and integer values are defined as 0.

Cause

When the geodatabase sets a NULL value for nullable attributes, the DBMS expects the attribute value to be NULL and therefore does not set the value to the attribute's default value.

Workaround

Create a trigger on the attribute table to set a value other than NULL during an insert.

The following is an Oracle example for creating a BEFORE INSERT trigger that sets an attribute value during an insert operation:

Code:
CREATE OR REPLACE TRIGGER before_insert_parcels
BEFORE INSERT ON parcels FOR EACH ROW

BEGIN

IF :NEW.appraisal_value IS NULL THEN
:NEW.appraisal_value := 0;
END IF;

END;
/


After a row is inserted into the parcels table and the appraisal_value is NULL, the trigger sets the appraisal_value to 0 prior to performing the INSERT into the table.