1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| with cte_datas (provitype, dateech, montae) as
(
select 'TRA', date '2017-07-01', 49.30 from dual union all
select 'TRA', date '2017-04-01', 47.84 from dual union all
select 'PLA', date '2017-07-01', 965.80 from dual union all
select 'PLA', date '2017-04-01', 965.80 from dual union all
select 'PLA', date '2017-10-01', 459.82 from dual union all
select 'PLA', date '2017-07-01', 459.82 from dual union all
select 'PLA', date '2017-10-01', 539.06 from dual union all
select 'PLA', date '2017-07-01', 539.06 from dual
)
select substr(XMLRoot(XMLAgg(XMLElement("planif",
XMLForest(provitype as "type",
XMLAgg(XMLElement("echeance",
XMLForest(dateech as "date", montae as "montant"))) as "echeances")) order by provitype desc),
version '1.0" encoding="UTF-8').getClobVal(), 40) as XML
from cte_datas
group by provitype;
<planif>
<type>TRA</type>
<echeances>
<echeance>
<date>2017-07-01</date>
<montant>49.3</montant>
</echeance>
<echeance>
<date>2017-04-01</date>
<montant>47.84</montant>
</echeance>
</echeances>
</planif>
<planif>
<type>PLA</type>
<echeances>
<echeance>
<date>2017-07-01</date>
<montant>965.8</montant>
</echeance>
<echeance>
<date>2017-07-01</date>
<montant>539.06</montant>
</echeance>
<echeance>
<date>2017-10-01</date>
<montant>539.06</montant>
</echeance>
<echeance>
<date>2017-07-01</date>
<montant>459.82</montant>
</echeance>
<echeance>
<date>2017-10-01</date>
<montant>459.82</montant>
</echeance>
<echeance>
<date>2017-04-01</date>
<montant>965.8</montant>
</echeance>
</echeances>
</planif> |
Partager