触发维护库存 [英] Trigger for maintaining stock
本文介绍了触发维护库存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有购买表,销售表.我也有一个当前表.想要使用触发器将项目添加和更新到currentstock表中.
在此先感谢
Hi
i have purchase, sales table . also i have a currentstock table. iwant to add and update items to currentstock table using triggers.
Thanks in advance
推荐答案
Man,您可以使用存储过程代替 trigger 进行此操作.
在存储过程中,为事务表&然后用于库存表.
示例看起来像
Man, you can use stored procedure instead of trigger for this operation.
Inside the stored procedure, write Insert query for the Transaction Table & then for Stock table.
example looks like
CREATE PROCEDURE UspSALES
(...arguments...)
BEGIN
INSERT INTO SALES_TABLE(...fields...) VALUES(...values...)
--STOCK SHOULD BE DECREASED
UPDATE STOCK_TABLE SET (...fields...)=(...values...)
END
CREATE PROCEDURE UspPURCHASE
(...arguments...)
BEGIN
INSERT INTO PURCHASE_TABLE(...fields...) VALUES(...values...)
--STOCK SHOULD BE INCREASED
UPDATE STOCK_TABLE SET (...fields...)=(...values...)
END
如果您有任何疑问,请告诉我
please let me know if you have any doubt
为什么要使用触发器?您确定它们是最好的解决方案吗?您尝试了什么?
Why do you want to use triggers ? Are you sure they are the best solution ? What have you tried ?
这篇关于触发维护库存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文