日期:2014-05-16  浏览次数:20867 次

mysql触发器错误
create trigger appInfo_trigger before update on appinfo for each row
  Begin
insert into appinfo_record(appId,appName,pgn,company,description,createUser,createTime,apptype,price,verName,verNumber,url,state,asmState,assessmentTime,asmResult,android2,android3,mtk1,mtk2,resolution1,resolution2,resolution3,testResult,testTime,remark,belongsUser,sendMailState,contractState)values(old.id,old.appName,old.pgn,old.company,old.description,old.createUser,old.createTime,old.apptype,old.price,old.verName,old.verNumber,old.url,old.state,old.asmState,old.assessmentTime,old.asmResult,old.android2,old.android3,old.mtk1,old.mtk2,old.resolution1,old.resolution2,old.resolution3,old.testResult,old.testTime,old.remark,
old.belongsUser,old.sendMailState,old.contractState);

if old.state=6 then

select @str=id from ui_application where package=old.pgn limit 1;

if str=0 then 

insert into ui_application(name,package,ver_name,ver_no,url,description,company,create_time,create_by,price,contractState)values(old.appName,old.pgn,old.verName,old.verNumber,old.url,old.description,old.createTime,old.createUser,old.price,old.contractState);

else 
update ui_application set name=old.appName,package=old.pgn,ver_name=old.verName,ver_no=old.verNumber,url=old.url,description=old.description,company=old.company,create_time=olc.createTime,create_by=old.createUser,price=old.price,contractState=old.contractState where id=str;
end if;

end if;

end;

各位大佬们,我的触发器创建老是提示:ERROR 1415 : Not allowed to return a result set from a trigger



------解决方案--------------------
select @str=id from ui_application where package=old.pgn limit 1;->
select id into @str from ui_application where package=old.pgn limit 1;
------解决方案--------------------
select @str=id from ui_application where package=old.pgn limit 1;

MYSQL中赋值是

select @str:=id from ui_application where package=old.pgn limit 1;
------解决方案--------------------
into 和:=都可以赋值