Re: default value not null not working as expected

Fred Toussi via Hsqldb-user <[email protected]> Fri, 25 May 2018 16:14:24 +0100
Newsgroups gmane.comp.java.hsqldb.user
Message-ID <1527261264.2257549.1385362312.05B86E6F@webmail.messagingengine.com>
The explicit null in the INSERT statement is not replaced with the default value.

These statements insert the default value:
insert into users (username, start_date, end_date) values ('jtam',  DEFAULT, null);
insert into users (username,  end_date) values ('jtam',  null);

Fred

On Fri, May 25, 2018, at 15:14, Joseph Tam wrote:
> Hi..
> 
> I am having trouble with the default value (setting current_timestamp)
> in hsql 2.4.1
> 
> when I take off the not null from the column, I can see that it is not
> populating the column with the default value, so the exception is
> valid.
> 
> when does the default value get used? thanks in advance!
> 
> details:
> 
> create table users
> (
>   id          bigint generated by default as identity(start with 1),
>   username varchar(255),
>   start_date  timestamp default current_timestamp not null,
>   end_date    timestamp
> );
> 
> insert into users (username, start_date, end_date) values ('jtam', null, null);
> 
> integrity constraint violation: NOT NULL check constraint;
> SYS_CT_11667 table: USERS column: START_DATE
> 
> -joe
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Hsqldb-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hsqldb-user

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot