Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

wrong sequence for 'select xmlagg(...) into ... order by ....'

user8704911Feb 21 2014 — edited Feb 21 2014

For the statement above i get a forrest of XML nodes in a wrong sequence.

I have a sequence of XML elements in a table:

[ sorry for this '<span><span><span><span><span><span>' stuff - i didn't find a way to remove it ]


T5100 = 4, seqno = 1

T5100 = 7, seqno = 2

T5100 = 10, seqno = 3

T5100 = 13, seqno = 4

T5100 = 16, seqno = 5

T5100 = 19, seqno = 6

T5100 = 22, seqno = 7

T5100 = 25, seqno = 8

T5100 = 37, seqno = 9

T5100 = 40, seqno = 10

T5100 = 43, seqno = 11

T5100 = 46, seqno = 12

T5100 = 49, seqno = 13

T5100 = 52, seqno = 14

T5100 = 55, seqno = 15

T5100 = 73, seqno = 16

T5100 = 76, seqno = 17

T5100 = 79, seqno = 18

T5100 = 106, seqno = 19

'T5100' is an XML attribute in the root node (<SEG9510>) of the aggregated xmltype data (column) from the source table (just used here as a token).

'seqno' is a sequence number (column) of the same source table - which is used for the 'order by'.

However my xmlserialize result goes like this:

<SEG9510 T5100="76"/>

<SEG9510 T5100="79"/>

<SEG9510 T5100="106"/>

<SEG9510 T5100="4"/>

<SEG9510 T5100="7"/>

Actually, the out-of-sequence elements (76-79-106) are always some, that appear in the beginning, but show be at the end (see above).

And this wrong-located subset itself is in-order (76-79-106).

For this i was not sure, if it is due to xmlagg(...) or xmlserialize(...).

So i picked up the 1st XML root element from the xmlagg(...) result (via 'extract') and logged that separately:

<SEG9510 T5100="76"/>

So the issue is about xmlagg(...).

So what's wrong here?

- many thanks!

best regards,

Frank

This post has been answered by Solomon Yakobson on Feb 21 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2014
Added on Feb 21 2014
3 comments
462 views