我正在尝试使用相同的更新语句更新两列可以完成吗?
IF V_COUNT = 9 THEN
UPDATE INVOICE
SET INV_DISCOUNT = DISC3 * INV_SUBTOTAL
, INV_TOTAL = INV_SUBTOTAL - INV_DISCOUNT
WHERE INV_ID = I_INV_ID;
DBMS_OUTPUT.PUT_LINE ('YOU QUALIFY FOR A DISCOUNT OF 30%');
问题是INV_TOTAL
没有更新,只有inv_discount
DISC3 = 0.3 IE 30% 折扣,所以 sub_total 将乘以 0.3,这就是 INV_discount 的值
INV_TOTAL = sub_total - 折扣
INV_ID|INV_DATETIME |INV_SUBTOTAL|INV_DISCOUNT| INV_TOTAL
----------|------------------------------|------------|------------|-----------
100|14-NOV-12 09.40.06.918000 | $.00| $.00| $.00
101|18-MAR-12 10.03.00.000000 | $.00| $.00| $.00
102|18-MAR-12 10.15.00.000000 | $.00| $.00| $.00
103|18-MAR-12 10.55.00.000000 | $80.00| $8.00| $72.00
104|18-MAR-12 10.38.00.000000 | $.00| $.00| $.00
105|12-JUN-12 15.15.00.000000 | $.00| $.00| $.00
106|06-AUG-12 12.13.00.000000 | $.00| $.00| $.00
107|04-MAY-12 09.15.00.000000 | $.00| $.00| $.00
108|29-NOV-12 13.16.00.000000 | $25.00| $5.00| $22.50
109|18-MAR-12 10.37.00.000000 | $50.00| $15.00| $45.00
108假设是 25 的 20%,折扣金额正确但 inv_total 不正确,应该是 $20,而不是 $22.50
109假设是 50 的 30% 折扣金额是正确的,但 inv_total 应该是 $35
103计算罚款,即10%折扣