Last answered:

27 May 2022

Posted on:

04 May 2022

0

error 1292 truncated incorrect double value mysql

I'm trying to execute below query I'm getting an error

0 2 13:58:35 insert into artists values(1275, 'John', 'johnson', '2009-01-18', 4, 10, 'signed to a record label', '2014-2-2', '2018-5-14', null) Error Code: 1292. Truncated incorrect DOUBLE value: 'not professional yet' 0.016 sec



drop trigger if exists trig_artist;
delimiter $$
create trigger trig_artist
before insert on artists
for each row
begin
if (year(date(sysdate()))-year((new.birth_date))) < 18 then
    set new.dependency = 'not professional yet'
    and
    new.no_weeks_top_100=0;
    end if;
end $$
delimiter ;

insert into artists values(1275, 'John', 'johnson', '2009-01-18', 4, 10, 'signed to a record label', '2014-2-2', '2018-5-14', null);



  image

1 answers ( 0 marked as helpful)
Instructor
Posted on:

27 May 2022

0

Hi Inderjeet!
Thanks for reaching out.

You do not need the AND keyword. Please, use the following code:
drop trigger if exists trig_artist;
delimiter $$
create trigger trig_artist
before insert on artists
for each row
begin
if (year(date(sysdate()))-year((new.birth_date))) < 18 then
    set new.dependency = "not professional yet",
    new.no_weeks_top_100=0;
    end if;
end $$
delimiter ;

Then run the query for the insertion.

Hope this helps.
Best,
Tsvetelin

Submit an answer