这是一个创建于 2956 天前的主题,其中的信息可能已经有所发展或是发生改变。
Create PROCEDURE Kucun(oid int,sid int)
begin
DECLARE s TINYINT;
DECLARE g TINYINT;
DECLARE n TINYINT;
DECLARE a TINYINT;
DECLARE cursorDone INT DEFAULT 0;
select status INTO s from iwebshop_seller_order where id=order_id and user_id=seller_id;
IF s=3 THEN
update iwebshop_seller_order set status ='4',confirm_time=now() where id=oid and user_id=sid;
DECLARE cur CURSOR FOR select goods_id,goods_nums from iwebshop_seller_order_goods where order_id = oid;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET cursorDone = 1;
open cur;
FETCH cur INTO g,n;
select count(*) INTO a from iwebshop_seller_kucun where seller_id=sid and gid=g;
IF a>0 THEN
update iwebshop_seller_kucun set num =num+n where gid=g and seller_id=sid;
ELSE
insert into iwebshop_seller_kucun VALUES ('',sid,g,n);
END IF;
CLOSE cur;
END IF;
end;