Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Null assigned to not nullable columns
Mon, Mar 19 2007 8:53 AMPermanent Link

"Ole Willy Tuv"
create table test
(
 col1 integer generated by default as identity not null,
 col2 varchar(30) default 'Value' not null
);

insert into test values (null,null);

select * from test

What happens here is that the null values are silently converted to the
default column values. This behavior seems inconsistent, one would expect
the insert statement to throw a constraint violation error when assigning
null to not nullable columns.

A better approach would IMO be to support/use the <default specification> to
explicitly specify default values:

insert into test values (default,default);

Ole Willy Tuv

Mon, Mar 19 2007 6:27 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< What happens here is that the null values are silently converted to the
default column values. This behavior seems inconsistent, one would expect
the insert statement to throw a constraint violation error when assigning
null to not nullable columns. >>

It's a sequencing issue due to what you mention below.  For now, the
expectation is in line with DBISAM in that any column with a default value
assigned won't raise a constraint error on an insert.

<< A better approach would IMO be to support/use the <default specification>
to explicitly specify default values: >>

I've got this on the list of enhancements.  I missed it in the initial
run-through.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image