Oracle BI 表达式错误

Error in Oracle BI expression

我正在尝试检查该字段是否为 0 或 null,如果是,剩余金额将等于发票金额。

出现这个错误,我搜索了一下,但一无所获!

代码如下:

IF (G_Invoice.Amount_Paid = 0 OR G_Invoice.Amount_Paid is null )

then

Remaining_Amount := G_Invoice.Invoice_Amount

else

G_Invoice.Invoice_Amount-G_Invoice.Amount_Paid

end if;

错误很容易解释(我在简短的评论中这样做了)。

但同样的结果可能更简单:

Remaining_Amount := G_Invoice.Invoice_Amount-NVL(G_Invoice.Amount_Paid, 0)

不需要 IF 语句(隐藏在 NVL 中)。无需将支付金额为零的情况视为特殊情况(如果减去 0,则与返回 INVOICE_AMOUNT 相同)。 NVL 将导致 null 转换为零。

如果在 Oracle BI 中计算度量,则 LSQL 代码应为:

Remaining_Amount - ifnull(G_Invoice.Amount_Paid,0)