xmlelement inside an xmlement ! [message #459329] |
Fri, 04 June 2010 07:07 |
b_52globemaster
Messages: 51 Registered: July 2005
|
Member |
|
|
Hi i'm having a view where i select the clob content of another view and it works , but replace the '<' and '>' by < and >
late's take this test case:
we create our first view:
CREATE OR REPLACE FORCE VIEW V_XML_test_data(id,xmlcontent) as
select 1,(
XMLELEMENT ("content",
XMLELEMENT ("delta",(select 1 from dual)),
XMLELEMENT ("omega",(select 2 from dual)),
XMLELEMENT ("gamma",(select 3 from dual))
)
).getclobval ()
from dual
and i got the second view where i select the result from the first one:
CREATE OR REPLACE FORCE VIEW V_XML_test_call(id,xmlcontent) as
select 1,(
XMLELEMENT ("result",
(SELECT XMLAGG (
XMLELEMENT ("delta",xmlcontent )
)from V_XML_test_data
)
)
).getclobval ()
from dual
the result appear like :
select xmlcontent from V_XML_test_call
Quote:
(CLOB) <result><delta> <content><delta>1</delta><omega>2</omega><gamma>3 </gamma></content> </delta></result>
any workaround?
and thanks
|
|
|
|
Re: xmlelement inside an xmlement ! [message #459338 is a reply to message #459336] |
Fri, 04 June 2010 07:43 |
_jum
Messages: 577 Registered: February 2008
|
Senior Member |
|
|
You should not use .getclobval() in your first view, compare your (simplified) queries:
SELECT
XMLELEMENT ("delta",(select 1 from dual)).getStringval() innerxml
FROM dual;
INNERXML
--------------------------------------------------------------
<delta>1</delta>
SELECT
XMLELEMENT("result",XMLELEMENT ("delta",(select 1 from dual)).getStringval()).getStringval() outer_rep
FROM dual;
OUTER_REP
--------------------------------------------------------------
<result><delta>1</delta></result>
SELECT
XMLELEMENT("result",XMLELEMENT ("delta",(select 1 from dual))).getStringval() outer_ok
FROM dual;
OUTER_OK
--------------------------------------------------------------
<result>delta>1</delta</result>
[Updated on: Fri, 04 June 2010 08:06] by Moderator Report message to a moderator
|
|
|
Re: xmlelement inside an xmlement ! [message #459352 is a reply to message #459329] |
Fri, 04 June 2010 08:27 |
b_52globemaster
Messages: 51 Registered: July 2005
|
Member |
|
|
_jum,Michel thanks
@_jum
yeap that did the job.
@Michel
i have a special scenario where i need to put some low level entities in the view which have some data under clob, and another view must bring some of the result of the first one depending on business rules.
thanks guys.
|
|
|
|
Re: xmlelement inside an xmlement ! [message #459382 is a reply to message #459362] |
Fri, 04 June 2010 09:58 |
_jum
Messages: 577 Registered: February 2008
|
Senior Member |
|
|
Would think so:
SET SERVEROUTPUT ON SIZE 1000000;
DECLARE
testClob CLOB;
BEGIN
SELECT
XMLELEMENT ("delta", (SELECT 1 FROM dual)).getclobval() INTO testClob
FROM DUAL;
DBMS_OUTPUT.put_line(testClob);
SELECT
REPLACE(XMLELEMENT ("delta", (SELECT 1 FROM dual)).getclobval(),'elta','oit') INTO testClob
FROM DUAL;
DBMS_OUTPUT.put_line(testClob);
END;
<delta>1</delta>
<doit>1</doit>
|
|
|
|
|