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

mysql 存储过程和触发器 都报错了
#
#添加触发器(当删除留言时,删除留言的回复)
#
  create tigger tri_Tb_Message_delete  
  after delete
  on tb_message 
  FOR Each row
  BEGIN 
  delete from Tb_Reply where Message_Id in (select Message_Id from deleted);
  End;  

#
#--添加存储过程(表名:Tb_Reply)
#insert
#
#
CREATE PROCEDURE pro_Tb_Reply_insert(
Message_Id int , --留言编号
Reply_Contents text, --回复内容
Reply_Time datetime='' --回复时间
)
BEGIN
Insert into Tb_Reply values(Message_Id,Reply_Contents,case is null (Reply_Time,'') when '' then getDate() when Reply_Time then Reply_Time end);
END;


给我帮我看看,貌似语法没有错,
[align=center][/align][align=left][/align]

------解决方案--------------------
DELIMITER $$
CREATE PROCEDURE pro_Tb_Reply_insert(
Message_Id int , --留言编号
Reply_Contents text, --回复内容
Reply_Time datetime='' --回复时间
)
BEGIN
Insert into Tb_Reply values(Message_Id,Reply_Contents,case is null (Reply_Time,'') when '' then getDate() when Reply_Time then Reply_Time end);
END$$
DELIMITER ;
------解决方案--------------------
当存储过程中有多个语句时,使用 delimiter // 来修改提交符。

delimiter //
create tigger tri_Tb_Message_delete 
after delete
on tb_message
FOR Each row
BEGIN
delete from Tb_Reply where Message_Id in (select Message_Id from deleted);
End;
//
------解决方案--------------------
delimiter$$
create tigger tri_Tb_Message_delete
after delete
on tb_message
FOR Each row
BEGIN
delete from Tb_Reply where Message_Id in (select Message_Id from deleted);
End$$
delimiter;