这是在商品出售时触发更改库存表的语法正确吗?
create trigger tr_stockquant
on tbl_ticket for insert, update, delete as $$
begin
update s set stockQty = s.stockQty - isnull(i.Qty,0) + isnull(d.Qty,0)
from tbl_stock s
left join inserted i
on s.itemID = i.itemID
left join deleted d on itemID = s.itemID
end;
$$ language plpgsql;