Solved

Converting XML File to XMLTYPE

Posted on 2008-10-14
2
1,515 Views
Last Modified: 2013-12-18
We are trying to load a XML text file to a Oracle XMLTYPE. Any suggestions on this would be really helpful.

Thanks in advance.
0
Comment
Question by:pras_gupta
2 Comments
 
LVL 27

Expert Comment

by:sujith80
ID: 22718594
You can use sqlloader to load your XMLs into your table.
The control file would look something like this.

---------------------------------------------
LOAD DATA
INFILE 'file_list.txt'
 APPEND INTO TABLE TBL1
 FIELDS TERMINATED BY ','
 (fname FILLER CHAR(10),
  val LOBFILE(fname) TERMINATED BY EOF)
---------------------------------------------

Where file_list.txt is a plain text file with the name of your xml documents.
For example the contents would look like:

one.xml
two.xml

Where one.xml and two.xml are the xml files to be loaded. and the column VAL is of XMLTYPE in your table.
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 125 total points
ID: 22720434
or use bfiles
DECLARE

    v_bfile   BFILE := BFILENAME ('DTEMP', 'test.xml');

    v_clob    CLOB;

    v_xml     XMLTYPE;

BEGIN

    DBMS_LOB.createtemporary (v_clob, TRUE);

    DBMS_LOB.OPEN (v_bfile, DBMS_LOB.lob_readonly);

    DBMS_LOB.loadfromfile (v_clob, v_bfile, DBMS_LOB.lobmaxsize);

    v_xml := XMLTYPE (v_clob)

END;

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to recover a database from a user managed backup

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now