CREATE OR REPLACE FUNCTION app.combo_min_stock() RETURNS TRIGGER AS$combo_sync$DECLARE combo_product_IDs INTEGER[] := array(SELECT combo_product_map.combo_productID FROM app.combo_product_map WHERE combo_product_map.productID=NEW.productID);DECLARE comboID INTEGER;BEGIN -- UPDATE MINIMUM STOCK FOR COMBO SKUS -- FOREACH comboID IN ARRAY combo_product_IDs LOOP UPDATE app.inventory SET good_stock = combo_data.min_good_stock,bad_stock = combo_data.min_bad_stock,to_be_updated = true FROM (SELECT product.productID,MIN(inventory.good_stock) as min_good_stock,MIN(inventory.bad_stock) as min_bad_stock FROM app.product,app.inventory,app.combo_product_map WHERE product.is_combo=true AND product.productID=comboID AND product.productID=combo_product_map.combo_productID AND combo_product_map.productID=inventory.productID GROUP BY product.productID) AS combo_data WHERE combo_data.productID=inventory.productID; END LOOP;END; $combo_sync$ LANGUAGE plpgsql;ALTER FUNCTION app.combo_min_stock() OWNER TO postgres;CREATE TRIGGER combo_sync AFTER UPDATE OF good_stock ON app.inventory FOR EACH ROW EXECUTE PROCEDURE app.combo_min_stock();
当我尝试在库存表中编辑good_stock列的值时,它会抛出这个错误:
An error has occurred:
ERROR: control reached end of trigger procedure without RETURN
CONTEXT: PL/pgsql function app.combo_min_stock()
这个查询有什么问题?
试试这个:END LOOP; RETURN NulL;总结
以上是内存溢出为你收集整理的PostgreSQL触发器错误:控制在没有RETURN的情况下到达触发器过程的结束全部内容,希望文章能够帮你解决PostgreSQL触发器错误:控制在没有RETURN的情况下到达触发器过程的结束所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)