1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
SQL>
SQL> With Data As (
2 Select XmlType('<?xml version="1.0" encoding="ISO-8859-1"?>
3 <bookstore>
4 <book category="COOKING">
5 <title lang="en">Everyday Italian</title>
6 <author>Giada De Laurentiis</author>
7 <year>2005</year>
8 <price>30.00</price>
9 </book>
10 <book category="CHILDREN">
11 <title lang="en">Harry Potter</title>
12 <author>J K. Rowling</author>
13 <year>2005</year>
14 <price>29.99</price>
15 </book>
16 <book category="WEB">
17 <title lang="en">XQuery Kick Start</title>
18 <author>James McGovern</author>
19 <author>Per Bothner</author>
20 <author>Kurt Cagle</author>
21 <author>James Linn</author>
22 <author>Vaidyanathan Nagarajan</author>
23 <year>2003</year>
24 <price>49.99</price>
25 </book>
26 <book category="WEB">
27 <title lang="en">Learning XML</title>
28 <author>Erik T. Ray</author>
29 <year>2003</year>
30 <price>39.95</price>
31 </book>
32 </bookstore>') As x_el
33 From Dual
34 )
35 Select x.ligNo,
36 x.Title,
37 x.Lang,
38 x.Author,
39 To_Number(x.Price, '999D99', 'nls_numeric_characters=''. ''') Price
40 From Data t,
41 XmlTable('for $i in /bookstore/book
42 return $i
43 '
44 Passing t.x_el
45 Columns LigNo For ORDINAlITY,
46 Title Varchar2(30) Path 'title',
47 Lang Varchar2(3) Path 'title/@lang',
48 Author Varchar2(10) Path 'author[1]',
49 Price Varchar2(15) Path 'price'
50 ) x
51 /
LIGNO TITLE LANG AUTHOR PRICE
---------- ------------------------------ ---- ---------- ----------
1 Everyday Italian en Giada De L 30
2 Harry Potter en J K. Rowli 29,99
3 XQuery Kick Start en James McGo 49,99
4 Learning XML en Erik T. Ra 39,95
SQL> |
Partager