[SOLVED] mysql: Column cannot be null
by mfoley from LinuxQuestions.org on (#6E04W)
I seem to have outsmarted myself. I have the following mysql query:
Code:update members set workEmail = 'user@thisdom.org' where firstName = 'JOE' and lastName = 'SMITH';When I run this I get:
Code:ERROR 1048 (23000) at line 1: Column 'changedBy' cannot be nullThis is certainly an error in the trigger:
Code:CREATE TRIGGER members_after_update AFTER UPDATE ON members
FOR EACH ROW
BEGIN
if coalesce(OLD.workEmail, '') <> coalesce(NEW.workEmail, '') then
INSERT INTO changelog (tableName,columnName,changedBy,changeTime,keyField,keyFieldExtra,oldValue,newValue)
values ('members','workEmail',@webuser,NOW(),NEW.employeeId,null,
case when OLD.workEmail is null then '' else OLD.workEmail end,
case when NEW.workEmail is null then '' else NEW.workEmail end);
end if;@webuser is a user define variable, but I don't find where it is supposed to get set. I've tried exporting webuser=myBashId, but that doesn't work.
I have a nearly clone system running on another computer and this works w/o problem, and on this computer I can do updates logging to this same changelog file when run from java.
I created the @webuser variable and I obviously got it working once upon a time, but I cannot remember how I did it!
Any ideas? How/where do I set a mysql user defined variable for a trigger outside the trigger?
Code:update members set workEmail = 'user@thisdom.org' where firstName = 'JOE' and lastName = 'SMITH';When I run this I get:
Code:ERROR 1048 (23000) at line 1: Column 'changedBy' cannot be nullThis is certainly an error in the trigger:
Code:CREATE TRIGGER members_after_update AFTER UPDATE ON members
FOR EACH ROW
BEGIN
if coalesce(OLD.workEmail, '') <> coalesce(NEW.workEmail, '') then
INSERT INTO changelog (tableName,columnName,changedBy,changeTime,keyField,keyFieldExtra,oldValue,newValue)
values ('members','workEmail',@webuser,NOW(),NEW.employeeId,null,
case when OLD.workEmail is null then '' else OLD.workEmail end,
case when NEW.workEmail is null then '' else NEW.workEmail end);
end if;@webuser is a user define variable, but I don't find where it is supposed to get set. I've tried exporting webuser=myBashId, but that doesn't work.
I have a nearly clone system running on another computer and this works w/o problem, and on this computer I can do updates logging to this same changelog file when run from java.
I created the @webuser variable and I obviously got it working once upon a time, but I cannot remember how I did it!
Any ideas? How/where do I set a mysql user defined variable for a trigger outside the trigger?