I have xml value stored in oracle table as below.
<?xml version="1.0" encoding="UTF-8" standalon="no"?>
<!DOCTYPE TRADE>
<TRADE>
<SOME_TAGS>
<TAG>
...
</TAG>
</SOME_TAGS>
<QTYS>
<QTY TYPE="Commission">
<NUM>0.0000</NUM>
<ID CLASS="Currency">USD</ID>
<QTY>
<QTY TYPE="TransactionFee">
<NUM>3.0000</NUM>
<ID CLASS="Currency">USD</ID>
<QTY>
<QTY TYPE="TFee">
<NUM>0.0000</NUM>
<ID CLASS="Currency">USD</ID>
<QTY>
<QTY TYPE="BFee">
<NUM>1.0000</NUM>
<ID CLASS="Currency">USD</ID>
<QTY>
</QTYS>
</TRADE>
I want to write select
query to get those QTY
tags whose NUM
value is not 0 and put it to columns. Values in columns depends on non-zero qtys.There can be trades who might have all 4 qtys with non-zero then there will be all values in columns or there can be trades which has few non-zeros qty so add only those who has non-zero values
I tried to get the data using extractvalue
function , i can extract value per tag but I want to make it more generic and dont want to write for extractvalue
function for each tag and then check if its num value is 0 or not.
Can I use something like xpath ? how to use this?
My expected result is as below
In above example, TradeA has only one set of qty non-zero value so it has selected only one set in select query whereas TradeB has 2 set of non-zero Qty values so it has added values in that many columns and so on.