bill表机构:(订单表)
+int id +
+int statua+状态主键
+date nowdate +
+int ctobreview_id + 外键表
ctobreview表机构:(评价表)
+id
+
billitem 是定单项表shop是店铺product是产品表create trigger mytrigger after update on bill
for each row
begin
DECLARE billId,reivewID,shopID,productID int ;
if(bill.status == 2 && bill.ctobreview_id == NULL && datediff(bill.nowdate,now())>15)
begin
set billId = bill.id;
--select id into billId from bill where status = 2 and ctobreview = null;
SELECT product_id into productID from billitem where bill_id = billId;
select shop_id into shopID from product where shop_id = productID;
insert into ctobReview values(2,null,null,10,10,10,10,shopID);
-- select @reviewID from inserted;
select last_insert_id();
update bill set ctobreview_id = reviewID where id = billId;
end
end
大家帮我改下个这个触发器 我对mysql不是很了解,谢谢啦
+int id +
+int statua+状态主键
+date nowdate +
+int ctobreview_id + 外键表
ctobreview表机构:(评价表)
+id
+
billitem 是定单项表shop是店铺product是产品表create trigger mytrigger after update on bill
for each row
begin
DECLARE billId,reivewID,shopID,productID int ;
if(bill.status == 2 && bill.ctobreview_id == NULL && datediff(bill.nowdate,now())>15)
begin
set billId = bill.id;
--select id into billId from bill where status = 2 and ctobreview = null;
SELECT product_id into productID from billitem where bill_id = billId;
select shop_id into shopID from product where shop_id = productID;
insert into ctobReview values(2,null,null,10,10,10,10,shopID);
-- select @reviewID from inserted;
select last_insert_id();
update bill set ctobreview_id = reviewID where id = billId;
end
end
大家帮我改下个这个触发器 我对mysql不是很了解,谢谢啦
不要需要返回 return null可以吗
如果不需要返回值,return null 可以吗
if(new.status == 2 && new.ctobreview_id == NULL && datediff(new.nowdate,now())>15)
begin
set billId = new.id;
改好之后为什么一直这样啊 难道还是版本问题
"check the manual that corresponds to your
mysql server version for the right syntax to use near"
[/align]
[align=center]==== 思想重于技巧 ====
[/align]
我刚刚接触mysql 不知道什么是delimiter 就不曾该过!
[align=center]==== 思想重于技巧 ====
[/align]
我用上面的代码试 错误提示还是那样
"check the manual that corresponds to your
mysql server version for the right syntax to use near delimiter"