|
|
|
|
Re: Doubt In Using Extract Value [message #346169 is a reply to message #345849] |
Sat, 06 September 2008 20:38 |
|
Barbara Boehmer
Messages: 9101 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
SCOTT@orcl_11g> COLUMN col1 FORMAT A20
SCOTT@orcl_11g> COLUMN col2 FORMAT A20
SCOTT@orcl_11g> SET AUTOPRINT ON
SCOTT@orcl_11g> VARIABLE cur_out REFCURSOR
SCOTT@orcl_11g> DECLARE
2 x XMLTYPE;
3 -- Cur_Out REFCURSOR;
4 BEGIN
5 x := xmlType('
6 <ArrayOfCostBO>
7 <CostBO XmlNodeCount="1">
8 <PeriodList Period="a" />
9 </CostBO>
10 <CostBO XmlNodeCount="2">
11 <PeriodList Period="b" />
12 <PeriodList Period="c" />
13 </CostBO>
14 </ArrayOfCostBO>');
15 open :Cur_Out for
16 SELECT EXTRACTVALUE(VALUE(tx), '/PeriodList/@Period') COL1,
17 EXTRACTVALUE(VALUE(t), '/CostBO/@XmlNodeCount') COL2
18 FROM TABLE (XMLSEQUENCE(EXTRACT(X, '/ArrayOfCostBO/CostBO'))) t,
19 TABLE (XMLSEQUENCE(EXTRACT(VALUE(t),'CostBO/PeriodList')))(+) tx;
20 END;
21 /
PL/SQL procedure successfully completed.
COL1 COL2
-------------------- --------------------
a 1
b 2
c 2
SCOTT@orcl_11g>
|
|
|