Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert xml to clob by maintaining formatting Oracle11g

987861Dec 1 2014 — edited Dec 4 2014

I have to store a variable of xmltype into a clob column. I am using getclobval() function to convert the xml into clob. However, the data gets stored as a string in the clob and the formatting is lost. Is there any way I can preserve xml format while converting xmltype to clob?

select xmlelement(info,xmlelement(name,'Sankalp'),xmlelement(surname,'Patil')) into xml1 from dual;
dbms_output.put_line(xml1.getClobval);

Output:

<INFO><NAME>Sankalp</NAME><SURNAME>Patil</SURNAME></INFO>

I want output as:

<INFO>
  <NAME>Sankalp</NAME>
  <SURNAME>Patil</SURNAME>
</INFO>

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2015
Added on Dec 1 2014
5 comments
3,784 views