|
|
|
|
|
|
|
|
|
|
|
Re: How to retrieve Number of occurences of a specic node in xml [message #606979 is a reply to message #601330] |
Fri, 31 January 2014 10:18 |
|
Barbara Boehmer
Messages: 9104 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Here are a couple of methods:
SCOTT@orcl12c> CREATE TABLE t_shippers
2 (shipper_id NUMBER,
3 render_xml CLOB)
4 /
Table created.
SCOTT@orcl12c> INSERT INTO t_shippers VALUES (76545,
2 '<SHIPMENT>
3 <PLACEMARK>first row of data</PLACEMARK>
4 <PLACEMARK>second row of data</PLACEMARK>
5 </SHIPMENT>'
6 )
7 /
1 row created.
SCOTT@orcl12c> SELECT COUNT (*)
2 FROM t_shippers,
3 XMLTABLE ('//PLACEMARK' PASSING XMLTYPE (t_shippers.render_xml))
4 WHERE shipper_id = 76545
5 /
COUNT(*)
----------
2
1 row selected.
SCOTT@orcl12c> SELECT XMLQUERY
2 ('count (//PLACEMARK)'
3 PASSING XMLTYPE (t_shippers.render_xml)
4 RETURNING CONTENT)
5 FROM t_shippers
6 WHERE shipper_id = 76545
7 /
XMLQUERY('COUNT(//PLACEMARK)'PASSINGXMLTYPE(T_SHIPPERS.RENDER_XML)RETURNINGCONTE
--------------------------------------------------------------------------------
2
1 row selected.
|
|
|