Skip to Content
0
Mar 05, 2019 at 12:38 PM

Sorting JDBC table data and mapping to hierarchical structure

40 Views

Hi,

I am getting data from JDBC table in below format and need to map structure in given format after sorting based on article storage loc and status.

Data fetch from table

article storage_loc stock_status qty
123 1000 A 5
123 1000 B 3
123 1010 A 6
123 1020 B 7
567 1000 A 10
123 1010 B 9

Expected output

<ItemIdentification>
<article>123
<storage_loc>1000
<stock_status>A
<qty>5</qty>
</stock_status>
<stock_status>B
<qty>3</qty>
</stock_status>
</storage_loc>
<storage_loc>1010
<stock_status>A
<qty>6</qty>
</stock_status>
<stock_status>B
<qty>9</qty>
</stock_status>
</storage_loc>
<storage_loc>1020
<stock_status>B
<qty>7</qty>
</stock_status>
</storage_loc>
</article>
<article>567
<storage_loc>1000
<stock_status>A
<qty>10</qty>
</stock_status>
</storage_loc>
</article>
</ItemIdentification>