`create table item_receive(itemid number,item_name varchar2(10)......qty number,units number.....)
`create table stock(item_name varchar2(10),........totalqty number,.....)
答案 0 :(得分:0)
如果你想
stock
尚未填充,请在item_name
表格中插入一行
存在,qty
中的item_receive
来更新行
表格到totalqty
,然后您可以考虑使用MERGE语句,如下所示:
MERGE INTO stock s
USING item_receive ir
ON s.item_name = ir.item_name
WHEN MATCHED THEN
UPDATE SET s.totalqty = s.totalqty + ir.qty
WHEN NOT MATCHED THEN
INSERT (item_name, ..., totalqty, ...)
VALUES (ir.item_name, ..., ir.qty, ...);