select subselect parse results oracle



温度提取:

CREATE GLOBAL TEMPORARY TABLE "TRANSACTION"."TEMP_EXTRACT" 
   (    
    "EXTRACT_ID" VARCHAR2(256 BYTE), 
    "APP_DATA_ID" VARCHAR2(256 BYTE), 
    "IT_DEBIT_BANKID" VARCHAR2(11 BYTE), 
    "IT_DEBIT_ACCOUNT" VARCHAR2(20 BYTE), 
    "IT_CREDIT_BANKID" VARCHAR2(11 BYTE), 
    "IT_CREDIT_ACCOUNT" VARCHAR2(20 BYTE), 
    "IT_INT_TRAN_ID" NUMBER(15,0), 
    "IT_HOST_TC" VARCHAR2(12 BYTE), 
    "IT_BAI_TRAN_CODE" NUMBER(3,0), 
    "IT_SWFT_TRAN_CODE" VARCHAR2(3 BYTE), 
    "IT_DESCR" VARCHAR2(120 BYTE), 
    "IT_CUST_REF_ID" VARCHAR2(30 BYTE), 
    "IT_TOTAL_DEBIT" NUMBER(15,3), 
    "IT_TOTAL_CREDIT" NUMBER(15,3), 
    "IT_SERIAL_NUM" NUMBER(11,0), 
    "IT_DR_CR_CODE" VARCHAR2(1 BYTE), 
    "IT_PRESENT_DESC" VARCHAR2(120 BYTE), 
    "IT_ENTRY_TIMESTAMP" TIMESTAMP (6) WITH TIME ZONE, 
    "IT_LAST_UPDATE_TIMESTAMP" TIMESTAMP (6) WITH TIME ZONE, 
    "IT_PRINT_OR_ELECT" VARCHAR2(1 BYTE), 
    "IT_AVAIL_BAL" NUMBER(15,3), 
    "OR_POST_DATE" DATE, 
    "OR_TRAN_DATE" TIMESTAMP (6), 
    "AD_ENTRY_DATE" DATE, 
    "AD_VALUE_DATE" DATE, 
    "ST_STAGE" VARCHAR2(35 BYTE), 
    "REF_BEN_REF" VARCHAR2(16 BYTE), 
    "REF_USR_REF" VARCHAR2(100 BYTE), 
    "REF_MID_REF" VARCHAR2(16 BYTE), 
    "REF_BATCH_NUM" VARCHAR2(7 BYTE), 
    "REF_SEQ_NUM" VARCHAR2(7 BYTE), 
    "REF_HOST_BLK_NUM" VARCHAR2(30 BYTE), 
    "REF_HOST_BAL_SEQ_NUM" VARCHAR2(30 BYTE), 
    "ACH_ID" NUMBER(38,0), 
    "ACH_SENDER_ID" VARCHAR2(256 BYTE), 
    "ACH_SENDER_IDTYPE" VARCHAR2(256 BYTE), 
    "ACH_RECEIVER_ID" VARCHAR2(256 BYTE), 
    "ACH_RECEIVER_IDTYPE" VARCHAR2(256 BYTE), 
    "ACH_PAYINFO_SEQ" VARCHAR2(256 BYTE), 
    "ACH_EXCH_RATE" NUMBER(38,3), 
    "ACH_EXCH_RATECODE" VARCHAR2(256 BYTE), 
    "ACH_PAYOR_BNKIDTYPE" VARCHAR2(256 BYTE), 
    "ACH_PAYOR_BNKID" VARCHAR2(256 BYTE), 
    "ACH_BEN_BNKIDTYPE" VARCHAR2(256 BYTE), 
    "ACH_BEN_BNKID" VARCHAR2(256 BYTE), 
    "ACH_BEN_ACCTID" VARCHAR2(256 BYTE), 
    "ACH_ACT_WTHNBNKIDTYPE" VARCHAR2(256 BYTE), 
    "ACH_ACT_WTHNBNKID" VARCHAR2(256 BYTE), 
    "ACH_INSTR_CODE" VARCHAR2(256 BYTE), 
    "ACH_INSTR_ADDINFO" VARCHAR2(256 BYTE), 
    "ACH_REMITINFO_1" VARCHAR2(256 BYTE), 
    "ACH_REMITINFO_2" VARCHAR2(256 BYTE), 
    "ACH_REMITINFO_3" VARCHAR2(256 BYTE), 
    "ACH_REMITINFO_4" VARCHAR2(256 BYTE), 
    "ACH_REG_REP1" VARCHAR2(256 BYTE), 
    "ACH_REG_REP2" VARCHAR2(256 BYTE), 
    "ACH_REG_REP3" VARCHAR2(256 BYTE), 
    "ACH_ENTRY_TIMESTAMP" TIMESTAMP (6) WITH TIME ZONE, 
    "ACH_LAST_UPDATETIMESTAMP" TIMESTAMP (6) WITH TIME ZONE, 
    "ACH_CRE_DT_TIME" TIMESTAMP (6), 
    "ACH_X12_INT_CTRLNUM" VARCHAR2(256 BYTE), 
    "ACH_X12_GRP_CTRLNUM" VARCHAR2(256 BYTE), 
    "ACH_X12_TRAN_CTRLNUM" VARCHAR2(256 BYTE), 
    "ACH_PMT_RCPTDTTIME" TIMESTAMP (6), 
    "ACH_PMT_FORMATCODE" VARCHAR2(256 BYTE), 
    "ACH_BIZ_FXCODE" VARCHAR2(256 BYTE), 
    "ACH_CRDR_FLAG" VARCHAR2(256 BYTE), 
    "ACH_BEN_ACCTTYPE" VARCHAR2(256 BYTE), 
    "ACH_TRACE_SEQID" VARCHAR2(256 BYTE), 
    "ACH_ENTRY_DATE" DATE, 
    "ACH_PAYMENT_DATE" DATE, 
    "ACH_ACH_COMPANYID" VARCHAR2(256 BYTE), 
    "ACH_CHANNEL" VARCHAR2(256 BYTE), 
    "ACH_TRAN_CODE" VARCHAR2(256 BYTE), 
    "ACH_INDIV_ID" VARCHAR2(256 BYTE), 
    "ACH_RDFI_NUM" VARCHAR2(256 BYTE), 
    "ACH_RDFI_ID" VARCHAR2(256 BYTE), 
    "ACH_RDFIBRNCH_CNTRY" VARCHAR2(256 BYTE), 
    "ACH_RECID_NUM" VARCHAR2(256 BYTE), 
    "ACH_RMTADVHNDL_CODE" VARCHAR2(256 BYTE), 
    "ACH_FILE_CTRL_NUM" VARCHAR2(256 BYTE), 
    "ACH_PMT_COUNT" VARCHAR2(256 BYTE), 
    "ACH_PMT_HASH_TOT" VARCHAR2(256 BYTE), 
    "ACH_ACH_COMPANYNAME" VARCHAR2(256 BYTE), 
    "ACH_CLOB_820" CLOB, 
    "ACH_SOURCE_INFO" VARCHAR2(256 BYTE), 
    "ACH_CUST_REF" VARCHAR2(256 BYTE), 
    "ACH_BEN_PARTY_IDENTIFIER" VARCHAR2(256 BYTE), 
    "ACH_CLOB2_820" CLOB, 
    "ACH_IAT_CODE1" VARCHAR2(256 BYTE), 
    "ACH_IAT_CODE2" VARCHAR2(256 BYTE), 
    "ACH_FOR_CORR" VARCHAR2(256 BYTE), 
    "ACH_FOR_CORR_NUM" VARCHAR2(256 BYTE), 
    "ACH_FOR_CORR_ID_QUAL" VARCHAR2(256 BYTE), 
    "ACH_FOR_CORR_ID" VARCHAR2(256 BYTE), 
    "ACH_FOR_CORR_CD" VARCHAR2(256 BYTE), 
    "ACH_ACH_FILE_ID" VARCHAR2(256 BYTE), 
    "WIRES_PAYOR_ACCT_ID" VARCHAR2(35 BYTE), 
    "WIRES_PAYOR_BNK_ID_TYPE" VARCHAR2(15 BYTE), 
    "WIRES_BEN_ACCT_ID" VARCHAR2(35 BYTE), 
    "WIRES_BEN_BNK_ID" VARCHAR2(35 BYTE), 
    "WIRES_SENDER_BNK_ID" VARCHAR2(256 BYTE), 
    "WIRES_SENDING_BNK_ID" VARCHAR2(35 BYTE), 
    "WIRES_ACCT_WITHINS_BNK_ID" VARCHAR2(35 BYTE), 
    "WIRES_ACCT_WITHINS_BNK_ID_TYPE" VARCHAR2(15 BYTE), 
    "WIRES_ACCT_SER_BNK_ID" VARCHAR2(35 BYTE), 
    "WIRES_ACCT_SER_BNK_ID_TYPE" VARCHAR2(15 BYTE), 
    "WIRES_WIRE_SENDER_BNK_ID" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_RECVR_BNK_ID" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_OMAD" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_IMAD" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_OB1" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_OB2" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_OB3" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_OB4" VARCHAR2(256 BYTE), 
    "WIRES_GRP_BTCHID" VARCHAR2(256 BYTE), 
    "WIRES_GRP_NBOFTXS" VARCHAR2(256 BYTE), 
    "WIRES_GRP_CTRL_SUM" VARCHAR2(256 BYTE), 
    "WIRES_PMT_INFID" VARCHAR2(256 BYTE), 
    "WIRES_PMT_NBOFTXS" VARCHAR2(256 BYTE), 
    "WIRES_PMT_CTRL_SUM" VARCHAR2(256 BYTE), 
    "WIRES_CRE_DT_TIME" TIMESTAMP (6), 
    "WIRES_WIRE_SEG_TIME" TIMESTAMP (6), 
    "WIRES_WIRE_SEG_FRB_APPL_TIME" TIMESTAMP (6), 
    "WIRES_X12_INT_CTRLNUM" VARCHAR2(256 BYTE), 
    "WIRES_X12_GRP_CTRLNUM" VARCHAR2(256 BYTE), 
    "WIRES_X12_TRAN_CTRLNUM" VARCHAR2(256 BYTE), 
    "WIRES_SOURCE" VARCHAR2(256 BYTE), 
    "WIRES_TEMPLATE" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_PMT_METH_MOP" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_PMT_MSG_TYPE" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_PMT_MSG_SUBTYPE" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_DIRECTION" VARCHAR2(256 BYTE), 
    "WIRES_WIRE_BBI" VARCHAR2(256 BYTE) 
    )
    ON COMMIT DELETE ROWS ;

ACH_ADDENDA:

CREATE TABLE "TRANSACTION"."ACH_ADDENDA" 
   (    "ACH_ID" VARCHAR2(256 BYTE) NOT NULL ENABLE, 
    "RMR_NUMBER" VARCHAR2(256 BYTE), 
    "RMR_CODE" VARCHAR2(256 BYTE), 
    "INVOICE_NUMBER" VARCHAR2(256 BYTE), 
    "RMR_PAID_AMT" VARCHAR2(256 BYTE), 
    "RMR_ORIG_AMT" VARCHAR2(256 BYTE), 
    "RMR_DISC_AMT" VARCHAR2(256 BYTE), 
    "RMR_DATE" DATE, 
    "REF_CODE" VARCHAR2(256 BYTE), 
    "REF_ID" VARCHAR2(256 BYTE), 
    "REF_NAME" VARCHAR2(256 BYTE), 
    "REF_INSTRUCTIONS" VARCHAR2(256 BYTE), 
    "ADX_INSTRUCTIONS" VARCHAR2(256 BYTE), 
    "ENT_NUMBER" VARCHAR2(256 BYTE), 
    "LAST_UPDATE_TIMESTAMP" TIMESTAMP (6)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 
 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "DATA01" ;
    SELECT DISTINCT
                  XMLELEMENT (
                       "ACCOUNT",
                       XMLAGG (
                          XMLELEMENT (
                             "ACCOUNT_INFO",
                             XMLELEMENT("BANK_ID",account_summary.bank_id),
                             XMLELEMENT("ACCOUNT_NUMBER",account_summary.account_number),
XMLFOREST("BNK_ID_TYPE",ACCOUNT_SUMMARY.BNK_ID_TYPE),
XMLFOREST(ACCOUNT_SUMMARY.CURR_BAL*100 AS "CURR_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.COLL_BAL*100 AS "COLL_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.AVG_COLL_BAL*100 AS "AVG_COLL_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.AVAIL_BAL*100 AS "AVAIL_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.ONE_DAY_FLOAT*100 AS "ONE_DAY_FLOAT"),
XMLFOREST(ACCOUNT_SUMMARY.TWO_DAY_FLOAT*100 AS "TWO_DAY_FLOAT"),
XMLFOREST(ACCOUNT_SUMMARY.THREE_DAY_FLOAT*100 AS "THREE_DAY_FLOAT"),
XMLFOREST(ACCOUNT_SUMMARY.AVG_CURR_BAL*100 AS "AVG_CURR_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.INTEREST_CURR_BAL*100 AS "INTEREST_CURR_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.PRCPL_BAL*100 AS "PRCPL_BAL"),
XMLFOREST(ACCOUNT_SUMMARY.BEG_LED*100 AS "BEG_LED"),
XMLFOREST(ACCOUNT_SUMMARY.LOAN_AVAIL_BAL*100 AS "LOAN_AVAIL_BAL"),  
XMLFOREST(ACCOUNT_SUMMARY.NUM_CREDITS AS "NUM_CREDITS"),
XMLFOREST(ACCOUNT_SUMMARY.NUM_DEBITS AS "NUM_DEBITS"),
xmlforest(account_summary.amt_credits*100 as "AMT_CREDITS"),
XMLFOREST(ACCOUNT_SUMMARY.AMT_DEBITS*100 AS "AMT_DEBITS"),
     XMLELEMENT (
      "TRANSACTIONS",
    (SELECT DISTINCT XMLAGG (
               XMLELEMENT (
                  "TRANSACTION",
                  XMLFOREST (

TE.it_INT_TRAN_ID,
            TE.IT_HOST_TC,
            TE.IT_BAI_TRAN_CODE,
            TE.IT_SWFT_TRAN_CODE,
            TE.IT_SERIAL_NUM,
            TE.IT_DESCR AS "TRANS_DESC",
            TE.IT_CUST_REF_ID,
            TE.IT_TOTAL_DEBIT*100 AS "TOTAL_DEBIT",
            TE.IT_TOTAL_CREDIT*100 AS "TOTAL_CREDIT",
            TE.IT_DR_CR_CODE,
            TE.IT_PRINT_OR_ELECT,
            TE.IT_AVAIL_BAL AS "AVAIL_BAL",
            TE.OR_POST_DATE,
            TE.OR_TRAN_DATE,
            TE.AD_ENTRY_DATE,
            TE.AD_VALUE_DATE,
            TE.ST_STAGE,
            TE.REF_BEN_REF,
            TE.REF_USR_REF,
            TE.REF_MID_REF,
            TE.REF_BATCH_NUM,
            TE.REF_SEQ_NUM,
            TE.REF_HOST_BLK_NUM,
            TE.REF_HOST_BAL_SEQ_NUM,
                TE.ACH_ID,
                                TE.ACH_SENDER_ID,
                                TE.ACH_SENDER_IDTYPE,
                                TE.ACH_RECEIVER_ID,
                                TE.ACH_RECEIVER_IDTYPE,
                                TE.ACH_PAYINFO_SEQ,
                                TE.ACH_EXCH_RATE,
                                TE.ACH_EXCH_RATECODE,
                                TE.ACH_PAYOR_BNKIDTYPE,
                                TE.ACH_PAYOR_BNKID,
                                TE.ACH_BEN_BNKIDTYPE,
                                TE.ACH_BEN_BNKID,
                                TE.ACH_BEN_ACCTID,
                                TE.ACH_ACT_WTHNBNKIDTYPE,
                                TE.ACH_ACT_WTHNBNKID,
                                TE.ACH_INSTR_CODE,
                                TE.ACH_INSTR_ADDINFO,
                                TE.ACH_REMITINFO_1,
                                TE.ACH_REMITINFO_2,
                                TE.ACH_REMITINFO_3,
                                TE.ACH_REMITINFO_4,
                                TE.ACH_REG_REP1,
                                TE.ACH_REG_REP2,
                                TE.ACH_REG_REP3,
                                TE.ACH_ENTRY_TIMESTAMP,
                                TE.ACH_LAST_UPDATETIMESTAMP,
                                TE.ACH_CRE_DT_TIME,
                                TE.ACH_X12_INT_CTRLNUM,
                                TE.ACH_X12_GRP_CTRLNUM,
                                TE.ACH_X12_TRAN_CTRLNUM,
                                TE.ACH_PMT_RCPTDTTIME,
                                TE.ACH_PMT_FORMATCODE,
                                TE.ACH_BIZ_FXCODE,
                                TE.ACH_CRDR_FLAG,
                                TE.ACH_BEN_ACCTTYPE,
                                TE.ACH_TRACE_SEQID,
                                TE.ACH_ENTRY_DATE,
                                TE.ACH_PAYMENT_DATE,
                                TE.ACH_ACH_COMPANYID,
                                TE.ACH_CHANNEL,
                                TE.ACH_TRAN_CODE,
                                TE.ACH_INDIV_ID,
                                TE.ACH_RDFI_NUM,
                                TE.ACH_RDFI_ID,
                                TE.ACH_RDFIBRNCH_CNTRY,
                                TE.ACH_RECID_NUM,
                                TE.ACH_RMTADVHNDL_CODE,
                                TE.ACH_FILE_CTRL_NUM,
                                TE.ACH_PMT_COUNT,
                                TE.ACH_PMT_HASH_TOT,
                                TE.ACH_ACH_COMPANYNAME,
                                TE.ACH_CLOB_820,
                                TE.ACH_SOURCE_INFO,
                                TE.ACH_CUST_REF,
                                TE.ACH_BEN_PARTY_IDENTIFIER,
                                TE.ACH_CLOB2_820,
                                TE.ACH_IAT_CODE1,
                                TE.ACH_IAT_CODE2,
                                TE.ACH_FOR_CORR,
                                TE.ACH_FOR_CORR_NUM,
                                TE.ACH_FOR_CORR_ID_QUAL,
                                TE.ACH_FOR_CORR_ID,
                                TE.ACH_FOR_CORR_CD,
                                TE.ACH_ACH_FILE_ID,
                   TE.WIRES_PAYOR_ACCT_ID,
                   TE.WIRES_PAYOR_BNK_ID_TYPE,
                   TE.WIRES_BEN_ACCT_ID,
                   TE.WIRES_BEN_BNK_ID,
                   TE.WIRES_SENDER_BNK_ID,
                   TE.WIRES_sending_bnk_id,
                   TE.WIRES_ACCT_WITHINS_BNK_ID,
                   TE.WIRES_ACCT_WITHINS_BNK_ID_TYPE,
                   TE.WIRES_ACCT_SER_BNK_ID,
                   TE.WIRES_ACCT_SER_BNK_ID_TYPE,
                   TE.WIRES_wire_sender_bnk_id,
                   TE.WIRES_WIRE_RECVR_BNK_ID,
                   TE.WIRES_WIRE_OMAD,
                   TE.WIRES_WIRE_IMAD,
                   TE.WIRES_WIRE_OB1,
                   TE.WIRES_WIRE_OB2,
                   TE.WIRES_WIRE_OB3,
                   TE.WIRES_WIRE_OB4,
                   TE.WIRES_GRP_BTCHID,
                   TE.WIRES_GRP_NBOFTXS,
                   TE.WIRES_GRP_CTRL_SUM,
                   TE.WIRES_PMT_INFID,
                   TE.WIRES_PMT_NBOFTXS,
                   TE.WIRES_PMT_CTRL_SUM,
                   TE.WIRES_CRE_DT_TIME,
                   TE.WIRES_WIRE_SEG_TIME,
                   TE.WIRES_WIRE_SEG_FRB_APPL_TIME,
                   TE.WIRES_X12_INT_CTRLNUM,
                   TE.WIRES_X12_GRP_CTRLNUM,
                   TE.WIRES_X12_TRAN_CTRLNUM,
                   TE.WIRES_SOURCE,
                   TE.WIRES_TEMPLATE,
                   TE.WIRES_WIRE_PMT_METH_MOP,
                   TE.WIRES_WIRE_PMT_MSG_TYPE,
                   TE.WIRES_WIRE_PMT_MSG_SUBTYPE,
                   TE.WIRES_WIRE_DIRECTION,
                   TE.WIRES_WIRE_BBI
                                            ) as "TRANS",
                                                     XMLFOREST ( 
                                                          (SELECT 
                                                          XMLAGG (
                                                            XMLELEMENT("PMTREL",
                                                               XMLFOREST(ACH_ADDENDA.RMR_CODE as "RMR_CODE",
                                                                          ACH_ADDENDA.INVOICE_NUMBER as "INVOICE_NUMBER",
                                                                          ACH_ADDENDA.RMR_PAID_AMT as "RMR_PAID_AMT",
                                                                          ACH_ADDENDA.RMR_ORIG_AMT as "RMR_ORIG_AMT",
                                                                          ACH_ADDENDA.RMR_DISC_AMT as "RMR_DISC_AMT",
                                                                          ACH_ADDENDA.RMR_DATE as "RMR_DATE",
                                                                          ACH_ADDENDA.REF_CODE as "REF_CODE",
                                                                          ACH_ADDENDA.REF_ID as "REF_ID",
                                                                          ACH_ADDENDA.REF_NAME as "REF_NAME",
                                                                          ACH_ADDENDA.REF_INSTRUCTIONS as "REF_INSTRUCTIONS",
                                                                          ACH_ADDENDA.ADX_INSTRUCTIONS as "ADX_INSTRUCTIONS" ,
                                                                          ACH_ADDENDA.ENT_NUMBER as "ENT_NUMBER"
                                                                     ) AS "PMTREL1"
                                                                     )
                                                                     )
                                                                     FROM temp_extract TE, ach_addenda
                                                                     WHERE TE.APP_DATA_ID = ach_addenda.ach_id
                                                                     AND TE.EXTRACT_ID = EXTRACT_ID
                                                                     AND TE.ST_STAGE  IN ('Payment Rejected', 'CLABE Payment Rejected', 'Payment Accepted', 'ACHPayment_Confirmed') 


                                                                     )AS "PMTRELINFO"
                                                                      ),
                                              XMLForest(
                                                              (SELECT  
                                                                  XMLAgg(
                                                                     XMLELEMENT("ADDRESS",
                                                                                XMLFOREST(ad.descr as "DESCR",
                                                                                ad.name as "NAME",
                                                                                ad.ADDRESS1 AS "ADDRESS1",
                                                                                ad.ADDRESS2 AS "ADDRESS2",
                                                                                ad.ADDRESS3 AS "ADDRESS3",
                                                                                ad.CITY AS "CITY",
                                                                                ad.STATE AS "STATE",
                                                                                ad.COUNTRY AS "COUNTRY",
                                                                                ad.MAILCODE AS "MAILCODE"
                                                                                          ) as "ADDR1" 
                                                                                )
                                                                         )
                                                                FROM temp_extract te, address ad
                                                                WHERE te.EXTRACT_ID  = EXTRACT_ID
                                                                AND (
                                                                      (TE.APP_DATA_ID = AD.WIRE_ID AND (ad.descr='Payor Address' 
                                                                                                    or ad.descr='Beneficiary Address' 
                                                                                                    OR ad.descr='Account With Institution Address' 
                                                                                                    or ad.descr='Intermediary Institution Address'
                                                                                                    or ad.descr='Wire Beneficiary Bank Address'
                                                                                                    OR ad.descr='Wire Sender Bank Address'
                                                                                                    or ad.descr='Account Servicing Institution'))
                                                                OR    (TE.APP_DATA_ID = AD.ACH_ID AND      (ad.descr='Payor Address' 
                                                                                                            or ad.descr='Beneficiary Address' 
                                                                                                            or ad.descr='Account With Institution Address'))
                                                                     )

                                        ) AS "ADDRESS_INFO" 
                                                             ), 
                                                            XMLForest(
                                                              (SELECT 
                                                                  XMLAgg(
                                                                     XMLELEMENT("AMOUNT",
                                                                                XMLFOREST(additional_amount.description as "DESCR",
                                                                                ADDITIONAL_AMOUNT.AMOUNT*100 AS "AMOUNT",
                                                                                additional_amount.CURRENCY as "CURRENCY"
                                                                                          ) as "AMT1" 
                                                                                )
                                                                         )
                                                                 FROM additional_amount, TEMP_EXTRACT TE 
                                                                 where te.it_int_tran_id=additional_amount.int_tran_id

                                                               ) AS "AMOUNT_INFO" 
                                                             )
                         ) 
                         )
                         FROM  TEMP_EXTRACT TE
                         WHERE TE.EXTRACT_ID = EXTRACT_ID
                         )                 )))).getClobVal ()
              INTO  v_xml
              FROM  account_summary
              WHERE account_summary.account_number = p_acct_num
              AND   ACCOUNT_SUMMARY.BANK_ID = P_BANK_ID
              AND   to_char(POST_DATE) = to_char(r_max_all_sameday);

--这只需要是表A(事务类型1)的临时表中的值的本地值,但在xml上,它也显示在事务类型2的输出中。我该如何使用其中的where查询使子选择成为本地的呢?谢谢你抽出时间。

输出如下:

<ACCOUNT>
<ACCOUNT_INFO>
 <BANK_ID>21</BANK_ID>
 <ACCOUNT_NUMBER>2533167775</ACCOUNT_NUMBER>
<TRANSACTIONS>
<TRANSACTION>
 <IT_INT_TRAN_ID>450814</IT_INT_TRAN_ID>
 <IT_CUST_REF_ID>1234600</IT_CUST_REF_ID>
 <IT_DR_CR_CODE>D</IT_DR_CR_CODE>
 <OR_POST_DATE>0017-03-15</OR_POST_DATE>
 <AD_ENTRY_DATE>0023-06-15</AD_ENTRY_DATE>
 <AD_VALUE_DATE>0017-03-15</AD_VALUE_DATE>
 <ST_STAGE>Payment Accepted</ST_STAGE>
 <ACH_SENDER_ID>ACHtestFTPS </ACH_SENDER_ID>
 <ACH_SENDER_IDTYPE>Unknown</ACH_SENDER_IDTYPE>
 <ACH_RECEIVER_ID>bbvacompass </ACH_RECEIVER_ID>
 <ACH_RECEIVER_IDTYPE>Unknown</ACH_RECEIVER_IDTYPE>
 <PMTRELINFO>
<PMTRELINFO>
 <RMR_CODE>IV</RMR_CODE>
 <INVOICE_NUMBER>5940009404</INVOICE_NUMBER>
 <RMR_PAID_AMT>200.0</RMR_PAID_AMT>
 <RMR_ORIG_AMT>0.0</RMR_ORIG_AMT>
 <RMR_DISC_AMT>0.0</RMR_DISC_AMT>
 <RMR_DATE>2015-06-23</RMR_DATE>
 <REF_CODE>PO</REF_CODE>
 <REF_ID>005001234501</REF_ID>
 <REF_NAME>3</REF_NAME>
 </PMTRELINFO>
 </TRANSACTION>
 <TRANSACTION>
 <IT_INT_TRAN_ID>2837</IT_INT_TRAN_ID>
 <OR_POST_DATE>2013-09-09</OR_POST_DATE>
 <AD_VALUE_DATE>2013-09-06</AD_VALUE_DATE>
 <ST_STAGE>HIFV4</ST_STAGE>
 <REF_MID_REF>130906100719F101</REF_MID_REF>
 <WIRES_PAYOR_ACCT_ID>875212 </WIRES_PAYOR_ACCT_ID>
 <WIRES_BEN_BNK_ID>270021163 </WIRES_BEN_BNK_ID>
 <WIRES_SENDER_BNK_ID>021000089 </WIRES_SENDER_BNK_ID>
 <WIRES_ACCT_WITHINS_BNK_ID_TYPE>Other</WIRES_ACCT_WITHINS_BNK_ID_TYPE>
 <WIRES_ACCT_SER_BNK_ID>CITIUS33XXX </WIRES_ACCT_SER_BNK_ID>
 <WIRES_ACCT_SER_BNK_ID_TYPE>Other</WIRES_ACCT_SER_BNK_ID_TYPE>
 <PMTRELINFO>
**<PMTRELINFO>
 <RMR_CODE>IV</RMR_CODE>
 <INVOICE_NUMBER>5940009404</INVOICE_NUMBER>
 <RMR_PAID_AMT>200.0</RMR_PAID_AMT>
 <RMR_ORIG_AMT>0.0</RMR_ORIG_AMT>
 <RMR_DISC_AMT>0.0</RMR_DISC_AMT>
 <RMR_DATE>2015-06-23</RMR_DATE>
 <REF_CODE>PO</REF_CODE>
 <REF_ID>005001234501</REF_ID>
 <REF_NAME>3</REF_NAME>
 </PMTRELINFO>**
 </TRANSACTION>
 </TRANSACTIONS>
 </ACCOUNT_INFO>
 </ACCOUNT>

PMTTRELINFO适用于第一个事务,而不是第二个事务。

查看PMTTRELINFO元素,链接这两个表的唯一标准是:

           WHERE TE.APP_DATA_ID = ach_addenda.ach_id
           AND TE.EXTRACT_ID = EXTRACT_ID

所以

  1. 似乎没有任何东西限制交易类型至1、或2或其他任何值,和/或
  2. 在没有表别名的情况下,第二个谓词可能无法按预期工作

但我同意其他人的观点——关于你真正想要实现的目标,这个例子很难效仿。

相关内容

  • 没有找到相关文章

最新更新