sql >> Base de Datos >  >> RDS >> Oracle

Cómo usar la función xmlconcat en Oracle

WITH vw_cdic_uci_detail AS ( SELECT 546 AS vcud_lei, 'BMO2100001200001' AS vcud_uci, 50 AS vcud_per FROM DUAL UNION ALL
                             SELECT 546 AS vcud_lei, 'BMO2100005500012' AS vcud_uci, 50 AS vcud_per FROM DUAL
                           )
SELECT XMLELEMENT( "BusProcess",
          XMLFOREST(
             XMLFOREST( '65443W404' AS "CUSIP",
                        100         AS "RUP",
                        2500        AS "ACB"
             ) AS "CRR"
          ),
          XMLELEMENT("LEI", vcud_lei),
          XMLCONCAT( AddModCDIC ) AS "AddModCDIC"
       )
  FROM ( SELECT vcud_lei,
                CASE
                   WHEN 1=1
                   THEN
                   XMLCONCAT(
                      XMLELEMENT("AddModCDIC",
                         XMLELEMENT("CDICData",
                            XMLAGG(
                                     XMLELEMENT("UCIData",
                                        XMLFOREST(vcud_uci AS "UCI",
                                                  vcud_per AS "InterestlnDeposit"
                                  )
                               )
                            )
                         )
                      )
                   ) 
                   ELSE NULL
                END AS AddModCDIC
           FROM vw_cdic_uci_detail
          GROUP BY vcud_lei
      ) a;