RE: Inserting a default null date

2009-05-15 Thread Andrew Braithwaite
To: mysql@lists.mysql.com Subject: Re: Inserting a default null date Hi, > I have a table with a column like: > > date date default null, > > If I enter an empty string in it, the default null value is added (as it > should). > > But if I enter an invalid date by mistak

Re: Inserting a default null date

2009-05-15 Thread Martijn Tonies
Hi, I have a table with a column like: date date default null, If I enter an empty string in it, the default null value is added (as it should). But if I enter an invalid date by mistake, the date -00-00 date date is entered instead of the default null, and this is not good. Can I do

Re: Inserting a default null date

2009-05-15 Thread Janek Bogucki
Hi Octavian, One approach is to use a trigger, mysql> set sql_mode = ''; mysql> create table temp_date(d date default null); mysql> create trigger temp_date_bi before insert on temp_date for each row set new.d = if(new.d = '-00-00', null, new.d); mysql> insert into temp_date(d) values('20