-----------genhccappl.sql--------------
drop table tbl_maprg_inap_appl_tmp1 ;
drop table tbl_maprg_inap_appl_tmp2 ;
drop table tbl_maprg_inap_card_tmp1 ;
drop table tbl_maprg_inap_card_tmp2 ;
CREATE TABLE tbl_maprg_inap_appl_tmp1
TABLESPACE TBS_MAPG_TEMP_OBJS
NOLOGGING
PCTFREE 0
AS
(
SELECT appl_ref AS appl_ref,
Max(ver_dte) AS ver_dte
FROM tbl_maprb_hcc_appl_appl
GROUP BY appl_ref
);
CREATE TABLE tbl_maprg_inap_appl_tmp2
TABLESPACE TBS_MAPG_TEMP_OBJS
NOLOGGING
PCTFREE 0
AS
(
SELECT a.*
FROM tbl_maprb_hcc_appl_appl a,
tbl_maprg_inap_appl_tmp1 b
WHERE a.appl_ref = b.appl_ref
AND a.ver_dte = b.ver_dte
);
CREATE TABLE tbl_maprg_inap_card_tmp1
TABLESPACE TBS_MAPG_TEMP_OBJS
NOLOGGING
PCTFREE 0
AS
(
SELECT appl_ref AS appl_ref,
Max(ver_dte) AS ver_dte
FROM tbl_maprb_hcc_appl_card
GROUP BY appl_ref
);
CREATE TABLE tbl_maprg_inap_card_tmp2
TABLESPACE TBS_MAPG_TEMP_OBJS
NOLOGGING
PCTFREE 0
AS
(
SELECT a.*
FROM tbl_maprb_hcc_appl_card a,
tbl_maprg_inap_card_tmp1 b
WHERE a.appl_ref = b.appl_ref
AND a.ver_dte = b.ver_dte
);
SET termout OFF
SET pause OFF
SET echo OFF
SET timing OFF
SET verify OFF
SET feedback OFF
SET heading OFF
SET newpage NONE
SET linesize 133
spool hccappl.dat
SELECT distinct RPad(nvl(To_Char(appl.VER_DTE,'yyyymmdd'),' '),8,' ')
||RPad(nvl(appl.APPL_REF,' '),12,' ')
||RPad(nvl(appl.APPL_STUS,' '),2,' ')
||RPad(nvl(appl.SRC_OF_APPL,' '),4,' ')
||RPad(nvl(appl.PRIM_APPL_CUS_ID_TYP,' '),1,' ')
||RPad(nvl(appl.PRIM_APPL_CUS_ID,' '),12,' ')
||RPad(nvl(To_Char(appl.APPL_RECV_DTE,'YYYYMMDD'),' '),8,' ')
||RPad(nvl(To_Char(appl.APPL_STUS_SET_DTE,'YYYYMMDD'),' '),8,' ')
||RPad(nvl(appl.SALE_FORCE_ID,' '),10,' ')
||RPad(nvl(To_Char(acbal.CD_CLOS_DTE,'YYYYMMDD'),' '),8,' ')
||RPad(nvl(to_char(acbal.CD_CR_LMT_HKE,'FM0999999999999.00'),'0000000000000.00'),16,' ')
||RPad(nvl(cd.FNL_DCSN,' '),2,' ')
||RPad(nvl(acbal.RECR_PGM_CDE,' '),4,' ')
||RPad(nvl(acbal.CD_PROD_TYP,' '),3,' ')
||RPad(nvl(appl.CD_COMB_ID,' '),4,' ')
||RPad(nvl(cd.PLAS_ID,' '),3,' ')
||RPad(nvl(acbal.CD_NO,' '),16,' ')
||RPad(nvl(acbal.HUB_AC_NO,' '),12,' ')
from (select * from TBL_MAPRB_HCC_ACBAL_DP
where ver_dte = (select max(ver_dte) from Tbl_maprb_hcc_acbal_dp)) acbal,
tbl_maprg_inap_appl_tmp2 appl, tbl_maprg_inap_card_tmp2 cd
where appl.appl_Ref = cd.appl_Ref (+) and cd.appl_Ref = acbal.appl_Ref (+) ;
spool off;
exit;
----------------------hccappl.bat------------
@echo off
set /p uid=Oracle ID:
set /p pw=Password:
set /p sn=Service Name:
md C:\hccappl\
echo Generating hccappl file ...
sqlplus %uid%/%pw%@%sn% @genhccappl.sql > C:\hccappl\run.log
if not errorlevel 0 goto err1
echo Batch Completed Successfully.
echo Please find the report in C:\hccappl\
pause
goto end
:err1
echo Error Occurred, please check log files in C:\hccappl\ for details
pause
goto end
:end
--------
the final file name is hccappl.dat. will be generated contained result data in it.