MySQL Forums
Forum List  »  Newbie

Trigger Empty String to NULL not working on last column
Posted by: Douglas Rose
Date: October 31, 2015 11:15AM

Hello Experts,

I am trying to replace my primary key columns that contain empty string with NULL, as the primary key do not allow NULL, this will effectively not allow empty strings in my primary keys.

It works great for 3 out of 4 of the primary keys, however the final one is not replacing empty string with NULL and is allows insert into the table!

The only difference I can see is that the field that is not working "sex", is the final column in the csv import file. Any ideas?

Thank you for the help, this is driving me crazy.

BEGIN
if new.year = '' then
set new.year = null;
end if;
if new.event_id = '' then
set new.event_id = null;
end if;
if new.round = '' then
set new.round = null;
end if;
if new.sex = '' then
set new.sex = null;
end if;
END

Options: ReplyQuote


Subject
Written By
Posted
Trigger Empty String to NULL not working on last column
October 31, 2015 11:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.