
The current behavior can be difficult to debug and the problem could go unnoticed since no errors are reported.

However, I believe that the trigger should return an error to the client. INSERT INTO RawData (LineItemID, PreState,CtimeIn,CtimeOut,PostState,Name,Value) VALUES (NULL, '1','1131405338.64','1131405338.6416','','Enter','11')Īs a application developer, this problem can be fixed by correcting the trigger to be Turns out you need to use CONACTWS instead. If str is NULL, the return value is 0 because NULL fails equality. The second should demonstrate the problem. I needed to CONCAT a string in MySQL statement but it had null values which where wrecking the statement. If CONCAT() is invoked from within the mysql client, binary string results display. Instead, I believe that this trigger should error out under such a condition and return an error to the client.Ĭreate the tables listed in description.

When the row contains a null value, FieldNameValues becomes null itself. However, The trigger has some abnormal behavior when we insert a row into RawData that contains a null value. Normally, when you insert a row into rawData, you get a trigger that inserts a row into ReplicationLog with a fieldNamevalues looking something like this CONCAT() returns NULL if any argument is NULL. 'ID=', NEW.ID,'|-|','LineItemID=', NEW.LineItemID,'|-|','CtimeIn=', NEW.CtimeIn,'|-|','CtimeOut=', NEW.CtimeOut,'|-|','Name=', NEW.Name,'|-|','Value=', NEW.Value,'|-|','PreState=', NEW.PreState,'|-|','PostState=', NEW.PostState) If programname is NULL, then CONCAT('-', programname) will also return NULL, which CONCATWS will handle correctly by ignoring what it sees as a single null argument. In addition, I have the following trigger that occurs after RawData inserts: You cannot make a BEFORE INSERT trigger to concatenate an auto. You can't change columns in an AFTER trigger. But in an AFTER INSERT trigger, it's too late to change the NEW.photo column of your row.

In a BEFORE INSERT trigger, the NEW.id value is NULL. TableName varchar(64) NOT NULL default '', CONCAT () returns NULL if any of its arguments are NULL. PostState varchar(100) NOT NULL default '', PreState varchar(100) NOT NULL default '', LineItemID int(10) unsigned default NULL,ĬtimeIn varchar(100) NOT NULL default '',ĬtimeOut varchar(100) NOT NULL default '', ID int(10) unsigned NOT NULL auto_increment,
