mysql过程转换为oracle~ 怎么处理?
CREATEDEFINER='root'@'%'TRIGGERledianv3_1.insert_productstockopeBEFOREINSERTONledianv...
CREATE
DEFINER = 'root'@'%'
TRIGGER ledianv3_1.insert_productstockope
BEFORE INSERT
ON ledianv3_1.product_stockope
FOR EACH ROW
BEGIN
UPDATE product_stockopeitems SET newnum = num WHERE opeid = new.id;
SET new.num = (SELECT SUM(num) FROM product_stockopeitems WHERE opeid = new.id);
IF new.opetype in (1,3) AND new.status=3 THEN
INSERT INTO product_stockinfor (memberid, wareid, proitemsid, forsale, stockhis, onselltime)
SELECT new.memberid,wareid,proitemsid,newnum,newnum,NOW() FROM product_stockopeitems WHERE opeid = new.id
ON DUPLICATE KEY UPDATE forsale = forsale + VALUES(forsale), stockhis = stockhis + VALUES(stockhis), offselltime = NULL;
END IF;
IF new.opetype = 2 AND new.status=3 THEN
UPDATE product_stockinfor a, product_stockopeitems b SET a.forsale = a.forsale - b.newnum,a.stockhis = a.stockhis - b.newnum
WHERE b.opeid = new.id AND a.memberid = new.memberid AND a.wareid = b.wareid AND a.proitemsid = b.proitemsid;
END IF;
END 展开
DEFINER = 'root'@'%'
TRIGGER ledianv3_1.insert_productstockope
BEFORE INSERT
ON ledianv3_1.product_stockope
FOR EACH ROW
BEGIN
UPDATE product_stockopeitems SET newnum = num WHERE opeid = new.id;
SET new.num = (SELECT SUM(num) FROM product_stockopeitems WHERE opeid = new.id);
IF new.opetype in (1,3) AND new.status=3 THEN
INSERT INTO product_stockinfor (memberid, wareid, proitemsid, forsale, stockhis, onselltime)
SELECT new.memberid,wareid,proitemsid,newnum,newnum,NOW() FROM product_stockopeitems WHERE opeid = new.id
ON DUPLICATE KEY UPDATE forsale = forsale + VALUES(forsale), stockhis = stockhis + VALUES(stockhis), offselltime = NULL;
END IF;
IF new.opetype = 2 AND new.status=3 THEN
UPDATE product_stockinfor a, product_stockopeitems b SET a.forsale = a.forsale - b.newnum,a.stockhis = a.stockhis - b.newnum
WHERE b.opeid = new.id AND a.memberid = new.memberid AND a.wareid = b.wareid AND a.proitemsid = b.proitemsid;
END IF;
END 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询