我試圖從PL/SQL中使用以下觸發轉換到MySQLPL/SQL語法MySQL的句法
特別是我想知道如何做到這一點:
1. FOR quantity in 1..:new.product_quantity
2. FOR row IN()
。
create or replace trigger "TRG_INSERT_BILL_PRODUCTS"
after insert on Bill_Products
for each row
begin
FOR quantity in 1..:new.product_quantity
LOOP
FOR row IN (
SELECT pa.article_id,pa.consist_quantity
FROM product_articles pa
WHERE pa.product_id=:new.product_id)
LOOP
update store
set store_quantity=store_quantity-row.consist_quantity
where article_id=row.article_id;
END LOOP;
END LOOP;
END;
觸發的說明: Store表已經store.article_id和該文章 Product_articles表store.store_quantity已經pa.product_id,pa.article_id(文章是一致的產品),pa.consist_quantity (的文章)
所以在插入一個產品的帳單後,我想找到他所有的文章,並降低store.article_id store.article_id,這將是product_quantity(多少產品的增加該法案)* consist_quantity(產品中的那篇文章)
非常感謝! – jovanMeshkov