|
-
Here is the view:
CREATE OR REPLACE VIEW vw_tran_smry (
lang_id,
clnt_ent_nm,
clnt_id,
cust_nm,
cust_no,
cust_pty_id,
cust_bas_no,
gfcid,
acct_no,
acct_id,
cust_ref,
bnk_ref,
bnk_nm,
val_dt,
ent_dt,
trd_ent_dt,
stmt_dt,
last_ent_dt,
cr_d_ind,
pmt_typ,
prod_typ,
prod_typ_des,
pmt_detl,
fthr_ref,
acct_nm,
br_cod,
brn_nm,
tran_ccy,
tran_amt,
tran_no,
bene,
tran_typ,
br_tax_id,
detail,
act_only,
as_of_dt,
legal_text,
total,
base_tran_amt,
base_ccy,
tran_ccy_deci_plac,
batch_no,
swift_tran_cd,
serial_no,
tran_cod,
br_pty_id )
AS
SELECT
A.lang_id,
clnt_ent_nm,
clnt_id,
cust_nm,
cust_no,
cust_pty_id,
cust_bas_no,
gfcid,
acct_no,
acct_id,
cust_ref,
bnk_ref,
bnk_nm,
val_dt,
ent_dt,
trd_ent_dt,
stmt_dt,
last_ent_dt,
cr_d_ind,
pmt_typ,
prod_typ,
prod_typ_des,
pmt_detl,
nvl(decode(A.tran_cod,'MSC',NULL,
nvl(tcm.tran_cod_des, tce.tran_cod_des)),
--BTR_UTIL.get_tran_desc(t1.tran_cod,tv.lang_id,as1.br_pty_id)),
nvl(fthr_ref,nvl(tvm2.typ_val_des, tve2.typ_val_des))) fthr_ref,
acct_nm,
br_cod,
brn_nm ,
tran_ccy,
tran_amt,
tran_no,
bene,
tran_typ,
br_tax_id,
detail,
act_only,
as_of_dt,
legal_text,
total,
base_tran_amt,
base_ccy,
tran_ccy_deci_plac,
batch_no,
swift_tran_cd,
serial_no,
A.tran_cod,
br_pty_id
from ( SELECT /*+ FIRST_ROWS ORDERED INDEX(t1 RDS_TRANSACTION_NDX_5) INDEX(s1 RDS_STATEMENT_IDX_5) */
--GENERAL ACCOUNT STATEMENT FIELDS
t1.tran_cod as tran_cod,
as1.br_pty_id as brn_id,
lg.lang_id as lang_id,
as1.clnt_nam as clnt_ent_nm,
as1.clnt_id as clnt_id,
as1.cust_lgl_nam as cust_nm,
nvl(as1.GFCID ,as1.CUST_BAS_NO) as cust_no,
decode(AS1.gfcid,null,AS1.cust_bas_PTY_id,AS1.gfcid_PTY_id) as cust_pty_id,
as1.cust_bas_no as cust_bas_no,
as1.gfcid as gfcid,
as1.acct_no as acct_no,
as1.acct_id as acct_id,
NVL(ref_no, othr_ref_no) as cust_ref,
t1.othr_ref_no as bnk_ref,
as1.bank_nam as bnk_nm,
t1.tran_val_dt as val_dt,
t1.tran_post_dt as ent_dt,
t1.tran_ent_dt as trd_ent_dt,
s1.stmt_dt as stmt_dt,
NULL as last_ent_dt,
t1.cr_dr_mrk as cr_d_ind,
t1.prod_cod as pmt_typ,
t1.prod_typ as prod_typ,
nvl(tvm1.typ_val_des,tve1.typ_val_des) as prod_typ_des,
t1.tran_detl as pmt_detl,
-- nvl(decode(t1.tran_cod,'MSC',NULL,
-- BTR_UTIL.get_tran_desc(t1.tran_cod,tv.lang_id,as1.br_pty_id)),
-- nvl(t1.fthr_ref_data,tv2.typ_val_des))
t1.fthr_ref_data as fthr_ref,
as1.acct_fam_nam as acct_nm,
as1.br_cod as br_cod,
as1.br_nam as brn_nm ,
t1.iso_ccy_cod as tran_ccy,
DECODE(t1.cr_dr_mrk, 'D ' , -1.0*t1.tran_amt,
'RC', -1.0*t1.tran_amt,
t1.tran_amt) as tran_amt,
t1.tran_no as tran_no,
DECODE(t1.CR_DR_MRK,'C ',tp2.ptcp_pty_nam,'RD', tp2.ptcp_pty_nam,
'D ', tp1.ptcp_pty_nam,'RC', tp1.ptcp_pty_nam,' ') as bene,
t1.tran_typ_cod as tran_typ,
b1.br_tax_id as br_tax_id,
t1.xtra_info as detail,
nvl(t1.act_ind,'N') as act_only,
to_date('01/01/1999','dd/mm/yyyy') as as_of_dt,
' ' as legal_text,
0 as total,
NVL(Decode(e4.math_actn,'M',
(decode(e3.math_actn,'M',1 / e3.conv_rt,1 * e3.conv_rt))* e4.conv_rt,
(decode(e3.math_actn,'M',1 / e3.conv_rt,1 * e3.conv_rt))/ e4.conv_rt)
,NVL((decode(e2.math_actn,'M',(decode(e1.math_actn,'M',1 * e1.conv_rt,1 / e1.conv_rt))/
e2.conv_rt,(decode(e1.math_actn,'M',1 * e1.conv_rt,1 / e1.conv_rt))*e2.conv_rt)),
NVL((decode(e6.math_actn,'M',(decode(e5.math_actn,'M',1 * e5.conv_rt,1 / e5.conv_rt))/
e6.conv_rt,(decode(e5.math_actn,'M',1 * e5.conv_rt,1 / e5.conv_rt))*e6.conv_rt)) ,
NVL( (decode(e2.math_actn,'M',(decode(e5.math_actn,'M',1 * e5.conv_rt,1 / e5.conv_rt))/
e2.conv_rt,(decode(e5.math_actn,'M',1 * e5.conv_rt,1 / e5.conv_rt))*e2.conv_rt)) ,
(decode(e6.math_actn,'M',(decode(e1.math_actn,'M',1 * e1.conv_rt,1 / e1.conv_rt))/
e6.conv_rt,(decode(e1.math_actn,'M',1 * e1.conv_rt,1 / e1.conv_rt))*e6.conv_rt) )))))*
DECODE(t1.cr_dr_mrk, 'D ' , -1.0*t1.tran_amt,
'RC', -1.0*t1.tran_amt,t1.tran_amt)
as base_tran_amt,
bc.iso_ccy_cod as base_ccy,
2 as tran_ccy_deci_plac,
rc1.batch_no as batch_no,
t1.swift_tran_cod as swift_tran_cd,
rc1.chq_ser_no as serial_no,
as1.br_pty_id as br_pty_id
from account_scpn as1,
rds_statement s1,
rds_transaction t1,
branch b1,
vw_language lg,
rds_thrd_pty_info tp1,
rds_thrd_pty_info tp2,
rds_remote_checking rc1,
currency bc,
exchange_rate e1,
exchange_rate e2,
exchange_rate e3,
exchange_rate e4,
exchange_rate e5,
exchange_rate e6,
type_values tve1,
type_values tvm1
where as1.acct_id = s1.acct_id and
s1.acct_sta_typ = 'PROCESSED' and
-- as1.acct_sta_typ = s1.acct_sta_typ and
s1.acct_id = t1.acct_id and
s1.stmt_no = t1.stmt_no and
s1.actv_ind = 'Y' and
t1.backval_ind is null and
t1.tran_no = tp1.tran_no(+) and
tp1.tpty_typ(+) = 'BENE' and
t1.tran_no = tp2.tran_no(+) and
tp2.tpty_typ(+) = 'ORDPTY' and
t1.tran_no = rc1.tran_no(+) and
as1.br_pty_id = b1.pty_id and
b1.pty_sta_typ = 'PROCESSED' and
-- as1.pty_sta_typ = b1.pty_sta_typ and
t1.iso_ccy_cod = e1.iso_ccy_cod(+) and
e1.bas_ccy_cod(+) = 'USD' and
e2.bas_ccy_cod(+) = 'USD' and
e1.prod_src_typ(+) = 'MCP' and
e2.prod_src_typ(+) = 'MCP' and
e1.actv_ind(+) = 'Y' and
e2.actv_ind(+) = 'Y' and
e2.iso_ccy_cod(+) = bc.iso_ccy_cod and
e3.bas_ccy_cod(+) = 'EUR' and
e3.prod_src_typ(+) = 'EMU' and
e3.actv_ind(+) = 'Y' and
e3.iso_ccy_cod(+) = bc.iso_ccy_cod and
e4.bas_ccy_cod(+) = 'EUR' and
e4.prod_src_typ(+) = 'EMU' and
e4.actv_ind(+) = 'Y' and
e4.iso_ccy_cod(+) = t1.iso_ccy_cod and
-- CHECK NYRS IF MCP MISSING 6/27/01 CHANGE T. HINES
e5.iso_ccy_cod(+) = t1.iso_ccy_cod and
e5.bas_ccy_cod(+) = 'USD' and
e5.prod_src_typ(+) = 'NYRS' and
e5.exch_rt_typ(+) = 'SPOT' and
e5.actv_ind(+) = 'Y' and
e6.bas_ccy_cod(+) = 'USD' and
e6.prod_src_typ(+) = 'NYRS' and
e6.exch_rt_typ(+) = 'SPOT' and
e6.actv_ind(+) = 'Y' and
e6.iso_ccy_cod(+) = bc.iso_ccy_cod and
t1.prod_typ = tve1.typ_val(+) and
tve1.typ_def(+) = 'PROD_TYP' and
tve1.lang_id(+) = 'en_US' and
((t1.prod_typ = tvm1.typ_val or
tvm1.typ_val is null ) and
tvm1.typ_def(+) = 'PROD_TYP' and
tvm1.lang_id(+) = lg.lang_id )) A,
type_values tve2,
type_values tvm2,
Transaction_code tcm
, Transaction_code tce
where A.swift_tran_cd = tve2.typ_val(+)
and tve2.typ_def(+) = 'SWIFTTRAN'
and tve2.lang_id(+) = 'en_US'
and (
A.swift_tran_cd = tvm2.typ_val(+)
and tvm2.typ_def(+) = 'SWIFTTRAN'
and tvm2.lang_id(+) = A.lang_id )
and tcm.tran_cod(+) = A.tran_cod
and tcm.lang_id(+) = A.lang_id
and tcm.pty_id(+) = A.brn_id
and TCM.TRAN_COD_STA_TYP(+) = 'PROCESSED'
and TCM.PTY_STA_TYP(+) = 'PROCESSED'
and tcm.lang_id(+) <> 'en_US'
and tcm.tran_cod(+) <> 'MSC'
and tce.tran_cod(+) = A.tran_cod
and tce.pty_id(+) = A.brn_id
and tce.TRAN_COD_STA_TYP(+) = 'PROCESSED'
and tce.PTY_STA_TYP(+) = 'PROCESSED'
and tce.lang_id(+) = 'en_US'
and tce.tran_cod(+) <> 'MSC'
Account_scpn table has 38162 rows.
rds_statement has 334709 rows.
rds_transaction has 1908111 rows.
branch has 265 rows
vw_language has 27 rows
rds_thrd_pty_info has 100866 rows
rds_remote_checking has 1354873 rows
currency has 208 rows
exchange_rate has 60827 rows
type_values has 42052 rows.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|