Translation

The oldest posts, are written in Italian. If you are interested and you want read the post in English, please use Google Translator. You can find it on the right side. If the translation is wrong, please email me: I'll try to translate for you.

lunedì, settembre 11, 2017

Using XML 09: SELECT, Part 3b/3

In the previous post I saw that the XQuery_string '/alertlog' return just one row. So my question is "what if I change the row-pattern from '/alertlog' to /alertlog/msg or /alertlog/msg/txt"?

Here the answere

XQuery_string: /alertlog/msg


As you can see, in this case there will be 6 rows: one for each element. And this is exactly what I want

SQL> SELECT rownum, t.*, tx.* from mytab t, 
  2> XMLTable('/alertlog/msg' PASSING t.XML_COLUMN) tx








XQuery_string: /alertlog/msg/txt


Also in this case I have 6 rows. But here I have only the <txt> element (it was my request)

SQL> SELECT rownum, t.*, tx.* from mytab t, 
  2> XMLTable('/alertlog/msg/txt' PASSING t.XML_COLUMN) tx


I skip the output between line 2 and 5.



XQuery_string: more examples


Here other two example: similar to the previous posts

SQL> SELECT rownum, t.*, tx.* from mytab t, 
  2> XMLTable('/alertlog/msg/[@pid="65370"]' PASSING t.XML_COLUMN) tx



SQL> SELECT rownum, t.*, tx.* from mytab t, 
  2> XMLTable('/alertlog/msg/[@pid="65263"]' PASSING t.XML_COLUMN) tx





and if I modify the search

SQL> SELECT rownum, t.*, tx.* from mytab t, 
  2> XMLTable('/alertlog/msg/[@pid="65370"]/txt' PASSING t.XML_COLUMN) tx



Part08 Index Part10

Nessun commento: