Solved

Converting XML File to XMLTYPE

Posted on 2008-10-14
2
1,522 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

809 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