السلام عليكم ورحمة الله و بركاتة
أنا إسمى هادى حميدة و أعمل Oracle Developer فىى شركة مصر لصناعة الكيماويات
لدى مشكلة فى أحد التقارير التى تحسب مقارنة لمديونية عميل فى تاريخين مختلفين
كتبت هذة SQL
SELECT a.CUST_ID ,
SUM(a.TOT_DB ) TOT_DB ,
SUM(a.TOT_CR ) TOT_CR ,SUM(c.TOT_DB ) TOT_depit,
SUM(c.TOT_CR ) TOT_credit ,
a.CUST_NAME ,b.description
FROM(تيمب تابل) RA_CUST_BALANCE (تيمب تابل)a ,ra_cust_flex_value b,RA_CUST_BALANCE1 c
where substr(a.segment3,1,5) = substr(b.flex_value,1,5) and
substr(c.segment3,1,5) = substr(b.flex_value,1,5)
GROUP BY a.CUST_ID, a.CUST_NAME ,b.description
HAVING SUM(a.TOT_DB) > SUM(a.TOT_CR) and
SUM(c.TOT_DB) >SUM(c.TOT_CR)
order by a.cust_id
وهم يأخذون البيانات من ذة ال function
unction AFTERPFORM_003_003 return boolean is
CURSOR CUR_S1 IS ( select a.AEL_ID ,
a.THIRD_PARTY_NUMBER , a.ACCOUNTING_DATE , a. third_party_name
, NVL(a.accounted_dr,0) ACCOUNTED_DR
, NVL(a.accounted_cr,0) ACCOUNTED_CR, b.segment3 from
xla_ar_rec_ael_sl_v a,gl_code_combinations b
where
a.code_combination_id = b.code_combination_id AND
--and a.third_party_id is not null and
to_date(to_char(a.accounting_date ,
'dd-mm-yyyy') , 'dd-mm-yyyy') <= :to_date AND
a.ACCT_LINE_TYPE IN ('REC' , 'UNAPP' , 'ACC','MISCCASH')
--and
--substr(B.SEGMENT3, 1,5) LIKE substr(:CUS_Type, 1,5)||'%'
and substr(B.SEGMENT3, 1,5) in('17111','17112','17121','17122','17131')
--gl_transfer_status = 'Y'
UNION
select a.AEL_ID , a.THIRD_PARTY_NUMBER ,
a.ACCOUNTING_DATE ,a.third_party_name ,
NVL(a.accounted_dr,0) ACCOUNTED_DR , NVL(a.accounted_cr,0) ACCOUNTED_CR ,b.segment3 from
xla_ar_inv_ael_sl_v a,gl_code_combinations b where
a.code_combination_id = b.code_combination_id and
--a.third_party_id is not null and
to_date(to_char(a.accounting_date , 'dd-mm-yyyy') , 'dd-mm-yyyy') <= :to_date and
a.ACCT_LINE_TYPE = 'REC'
-- and
--substr(B.SEGMENT3, 1,5) LIKE substr(:CUS_Type, 1,5)||'%'
and substr(B.SEGMENT3, 1,5) in('17111','17112','17121','17122','17131'));
--gl_transfer_status = 'Y'
begin
:orientation := 'PORTRAIT' ;
DELETE FROM RA_CUST_BALANCE ;
FOR V_REC IN CUR_S1 LOOP
INSERT INTO RA_CUST_BALANCE1 VALUES ( V_REC.THIRD_PARTY_NUMBER , V_REC.ACCOUNTED_DR , V_REC.ACCOUNTED_CR , V_REC. third_party_name ,v_rec.segment3) ;
END LOOP ;
COMMIT ;
return (TRUE) ;
end;
و يوجد function اخر الجدول التانى RA_CUST_BALANCE و لا يظهر ناتج
فما المشكلة
نرجو الإفادة