Default values which do not match the datatype of field cause errors on insert

By: Quinn Wildman

Abstract: "arithmetic exception, numeric overflow, or string truncation error" or "conversion error" errors can occur.

If you create a default value for a field which cannot be stored in the field inserting data will generate an error.

Example 1:

create table t1(myfield_ok char(3) default 'ABC', myfield_error char(3) default 'ABCD');
insert into t1 ('A','A');

results in the error:

arithmetic exception, numeric overflow, or string truncation error

Example 2:

create table t2 (F1 int, F2 int default 'A')
insert into t2 values (1,1)

results in the error:

conversion error

Server Response from: ETNASC04