获取 Dr 和 Cr 客户明智会计的总和

问题描述 投票:0回答:1

甲骨文表格:12

Weblogic:12.0.01

Oracle 数据库:19 c

代码是在‘当新表单实例’oracle表单下触发的

declare
CURSOR c1 IS

SELECT id, Customer, SUM(DEBIT ) as Debit, abs(SUM(Payment )) as PAYMENT
FROM
(
SELECT
Cust_id as id,
cust_name as customer,
OPENING_BLNC as Debit,
0 as PAYMENT FROM Customer
union all
select
c.Cust_id as id,
c.cust_name as customer,
i.total_amount as Debit,
0 as PAYMENT
FROM Customer c,transaction t,invoice i where t.tran_id=i.inv_tran_id and c.cust_id=t.cust_id
union all
select
c.Cust_id as id,
c.cust_name as customer,
0 as Debit,
a.cr as PAYMENT
FROM Customer c,accounts a where c.cust_id=a.cust_id
)
GROUP BY id, Customer order by id desc ;

begin

FOR lop1 IN c1
loop
:block28.id:=lop1.id;
:block28.customer:= lop1.customer;
:block28.debit:=lop1.debit;
:block28.payment:= lop1.payment;
END LOOP;

end;

这段代码的输出是::

ID Customer Total dues Total Payment

1 KARIMULLAH 68697.04 40000

结果输出应该是。

ID Customer Total dues Total Payment

3 AZAD MEDIICE 21519.62 5000

2 NEW KARIM AGENCY 0 10000

1 KARIMULLAH 68697.04 40000
oracle oracleforms
1个回答
0
投票

那是因为您一遍又一遍地覆盖相同的表格形式行。您必须移至下一条记录,即

FOR lop1 IN c1
loop
  :block28.id       :=lop1.id;
  :block28.customer := lop1.customer;
  :block28.debit    :=lop1.debit;
  :block28.payment  := lop1.payment;

  next_record;              --> this
END LOOP;
© www.soinside.com 2019 - 2024. All rights reserved.