当开具新发票时,分销商表中的“sold”属性需要递增。
invoice_ty如下:
create or replace type invoice_ty as object(
Invoice_no VARCHAR(10),
distributor ref distributor_ty,
customer ref customer_ty,
price NUMBER(6, 2)
);
Create or replace type Distributor_ty as object (
VAT VARCHAR(15),
Seq_No NUMBER,
Sold NUMBER,
Address Distributor_address_ty)
NOT FINAL;
此触发器返回可变表错误:
create or replace trigger increment_sold
after insert on invoice
for each row
BEGIN
update distributor set sold = sold + 1 where distributor.vat = treat(:new.distributor as ref distributor_ty).vat;
END;
有什么建议吗
1条答案
按热度按时间wbgh16ku1#
使用复合触发器并收集分发服务器,以便从
invoice
表更新到AFTER EACH ROW
子句中的集合中,然后更新AFTER STATEMENT
子句中的distributors
表:fiddle