0

我正在尝试使用 Invoice 表中的一些值来计算此函数中的应付余额。我不太确定计算线的确切位置。任何帮助将非常感激!

Create or Replace Function Get_balance_due(
f_invoice_id In Number)
Return Number
AS
    balance_due Number;
    f_invoice_total Number;
    f_payment_total Number;
    f_credit_total Number;


Begin
    select (vendor_id into f_vendor_id,
    invoice total into f_invoice_total,
    payment_total into f_payment_total,
    credit_total into f_credit_total)

From
    invoices
Where
    invoice_id = f_invoice_id
    balance_due = f_invoice_total - f_payment_total - f_credit_total;
Return (balance_due);
End;
/
SHOW ERRORS Function Get_balance_due;
4

1 回答 1

0

像这样试试

CREATE OR REPLACE 
FUNCTION get_balance_due(
         f_invoice_id IN NUMBER)
         RETURN NUMBER
AS
     balance_due NUMBER;
     f_invoice_total NUMBER;
     f_payment_total NUMBER;
     f_credit_total NUMBER;

BEGIN
     SELECT invoice total, payment_total, credit_total
     INTO  f_invoice_total, f_payment_total, f_credit_total
     FROM  invoices
     WHERE invoice_id = f_invoice_id;

     balance_due := f_invoice_total - f_payment_total - f_credit_total;

RETURN balance_due;
END;
于 2013-09-26T06:42:46.350 回答