madi
12-10-2011, 07:30 PM
I worte some query in my database that all of them run with out any problem. but when I put them in an event that do them regularly, I face with this error. I tried this event several times and I understood that from where I put "insert into" code it doesnt work. I cant understand what is the problem. please guide me.
error in mysql:
#1048 - Column 'userid' cannot be null
query:
select @year:=extract(year from CURDATE());
select @month:=extract(month from CURDATE());
select @day:=extract(day from CURDATE());
select @id:=thanksid2, @uid:=userid, @sname:=sendername,@rname:=recivername,@remail:=reciveremail,@text:=text,@attach:=attach,@score:=sco re,@cost:=cost,@syear:=sendyear,@smonth:=sendmonth,@sday:=sendday,@subj:=subject,@tempid:=tempid,@dr aftid:=draftid from thanksmsg2 where sendyear=@year and sendmonth=@month and sendday=@day;
insert into thanksmsg1(thanksid1,userid,sendername,recivername,reciveremail,text,attach,score,cost,sendyear,send month,sendday,subject,tempid,draftid)values(@id,@uid,@sname,@rname,@remail,@text,@attach,@score,@cos t,@syear,@smonth,@sday,@subj,@tempid,@draftid);
delete from thanksmsg2 where thanksid2=@id;
event:
CREATE EVENT madi ON SCHEDULE EVERY 1 DAY DO
select @year:=extract(year from CURDATE());
select @month:=extract(month from CURDATE());
select @day:=extract(day from CURDATE());
select @id:=thanksid2, @uid:=userid, @sname:=sendername,@rname:=recivername,@remail:=reciveremail,@text:=text,@attach:=attach,@score:=sco re,@cost:=cost,@syear:=sendyear,@smonth:=sendmonth,@sday:=sendday,@subj:=subject,@tempid:=tempid,@dr aftid:=draftid from thanksmsg2 where sendyear=@year and sendmonth=@month and sendday=@day;
insert into thanksmsg1(thanksid1,userid,sendername,recivername,reciveremail,text,attach,score,cost,sendyear,send month,sendday,subject,tempid,draftid)values(@id,@uid,@sname,@rname,@remail,@text,@attach,@score,@cos t,@syear,@smonth,@sday,@subj,@tempid,@draftid);
delete from thanksmsg2 where thanksid2=@id;
error in mysql:
#1048 - Column 'userid' cannot be null
query:
select @year:=extract(year from CURDATE());
select @month:=extract(month from CURDATE());
select @day:=extract(day from CURDATE());
select @id:=thanksid2, @uid:=userid, @sname:=sendername,@rname:=recivername,@remail:=reciveremail,@text:=text,@attach:=attach,@score:=sco re,@cost:=cost,@syear:=sendyear,@smonth:=sendmonth,@sday:=sendday,@subj:=subject,@tempid:=tempid,@dr aftid:=draftid from thanksmsg2 where sendyear=@year and sendmonth=@month and sendday=@day;
insert into thanksmsg1(thanksid1,userid,sendername,recivername,reciveremail,text,attach,score,cost,sendyear,send month,sendday,subject,tempid,draftid)values(@id,@uid,@sname,@rname,@remail,@text,@attach,@score,@cos t,@syear,@smonth,@sday,@subj,@tempid,@draftid);
delete from thanksmsg2 where thanksid2=@id;
event:
CREATE EVENT madi ON SCHEDULE EVERY 1 DAY DO
select @year:=extract(year from CURDATE());
select @month:=extract(month from CURDATE());
select @day:=extract(day from CURDATE());
select @id:=thanksid2, @uid:=userid, @sname:=sendername,@rname:=recivername,@remail:=reciveremail,@text:=text,@attach:=attach,@score:=sco re,@cost:=cost,@syear:=sendyear,@smonth:=sendmonth,@sday:=sendday,@subj:=subject,@tempid:=tempid,@dr aftid:=draftid from thanksmsg2 where sendyear=@year and sendmonth=@month and sendday=@day;
insert into thanksmsg1(thanksid1,userid,sendername,recivername,reciveremail,text,attach,score,cost,sendyear,send month,sendday,subject,tempid,draftid)values(@id,@uid,@sname,@rname,@remail,@text,@attach,@score,@cos t,@syear,@smonth,@sday,@subj,@tempid,@draftid);
delete from thanksmsg2 where thanksid2=@id;