XML Data into table
Hello
Sorry, for the next question, but it doens't wort :-(...
I want to insert this xmldata into a table:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<aps:Operations xmlns:aps="Software" aps_version="V4.02-03.00" aps_versionl="4020300">
<Event>
<name>Dispatcher</name>
<dtsysl>20110428</dtsysl>
<hrsysl>95835</hrsysl>
<dtcptl>20110428</dtcptl>
<nusesi>1</nusesi>
<DSP>
<step>WAIT</step>
<state>Start</state>
</DSP>
</Event>
</aps:Operations>
CREATE OR REPLACE DIRECTORY test_dir AS '/oracle/temp/';
CREATE TABLE test_xml
(name VARCHAR (40),
dtsysl DATE,
hrsysl NUMBER,
dtcptl DATE,
nusesi NUMBER,
step VARCHAR (40),
state VARCHAR (40) );
INSERTINTO test_xml (name, dtsysl,hrsysl,dtcptl,nusesi,step,state)
SELECT *
FROM XMLTABLE (
'/ROWSET/ROW'
PASSING xmltype (BFILENAME (TEST_DIR', 'test.xml'), NLS_CHARSET_ID ('CHAR_CS'))
COLUMNS name VARCHAR (40) path 'name',
dtsysl DATE path 'dtsysl',
hrsysl NUMBER path 'hrsysl',
dtcptl DATE path 'dtcptl',
nusesi NUMBER path 'nusesi',
step VARCHAR (40) path 'step',
state VARCHAR (40) path 'state');
The message is always "0 rows inserted".
Thanks for your support.
roger
Edited by: Street on 28.04.2011 04:31
Edited by: Street on 28.04.2011 04:36
Apparently, you're using sample code from another example?
The problem is the use of "/ROWSET/ROW", there's no such path in the XML document, hence XMLTable returning nothing.
In your case the correct query would be :
SELECT *
FROM XMLTABLE (
XMLNamespaces('Software' as "aps"),
'/aps:Operations/Event'
PASSING xmltype (BFILENAME ('TEST_DIR', 'test.xml'), NLS_CHARSET_ID ('CHAR_CS'))
COLUMNS name VARCHAR (40) path 'name',
dtsysl DATE path 'dtsysl',
hrsysl NUMBER path 'hrsysl',
dtcptl DATE path 'dtcptl',
nusesi NUMBER path 'nusesi',
step VARCHAR (40) path 'DSP/step',
state VARCHAR (40) path 'DSP/state'
);See the XQuery expression "/aps:Operations/Event", it represents the access path of the element you consider as the record of data.
Hope that helps.
Similar Messages
-
Loading this xml data into tables
Hello,
I am having a problem loading this XML file into tables. The xml file structure is
<FILE>
<ACCESSION>
some ids
<INSTANCE>
some data
<VARIATION
</VARIATION>
<VARIATION>
</VARIATION> variation gets repeated a number of times
<ASSEMBLY>
</ASSEMBLY>
<ASSEMBLY>
</ASSEMBLY> Assembly gets repeated a number of times.
</INSTANCE>
</ACCESSION>
</FILE>
I created a table which has the structure:
create table accession(
accession_id varchar2(20),
Instance instance_type);
create or replace type instance_type as object
(method varchar2(20),
class varchar2(20),
source varchar2(20),
num_char number(10),
variation variation_type,
assembly assembly_type)
create or replace type variation_type as object
(value varchar2(2),
count number(10),
frequency number(10),
pop_id varchar2(10)
Created a similiar type for assembly.
When I load it, I could only store the first variation data but not the subsequent ones. Similarly for assembly I could only store the first data but not the subsequent ones.
Could anyone let me know how I could store this data into tables? I have also included a sample XML file in this message.
Thank You for your help.
Rama.
Here is the sample xml file.
<?xml version="1.0" ?>
- <FILE>
- <ACCESSION>
<ACCESSION_ID>accid1</ACCESSION_ID>
- <INSTANCE>
<METHOD>method1</METHOD>
<CLASS>class1</CLASS>
<SOURCE>source1</SOURCE>
<NUM_CHAR>40</NUM_CHAR>
- <VARIATION>
<VALUE>G</VALUE>
<COUNT>5</COUNT>
<FREQUENCY>66</FREQUENCY>
<POP1>pop1</POP1>
<POP2>pop1</POP2>
</VARIATION>
<VARIATION>
<VALUE>C</VALUE>
<COUNT>2</COUNT>
<FREQUENCY>33</FREQUENCY>
<POP_ID1>pop2</POP_ID1>
</VARIATION>
- <ASSEMBLY>
<ASSEMBLY_ID>1</ASSEMBLY_ID>
<BEGIN>180</BEGIN>
<END>180</END>
<TYPE>2</TYPE>
<ORI>-</ORI>
<OFFSET>0</OFFSET>
</ASSEMBLY>
- <ASSEMBLY>
<ASSEMBLY_ID>2</ASSEMBLY_ID>
<BEGIN>235</BEGIN>
<END>235</END>
<TYPE>2</TYPE>
<ORI>-</ORI>
<OFFSET>0</OFFSET>
</ASSEMBLY>
</INSTANCE>
</ACCESSION>
</FILE>Hello,
I could figure out how to load this XML file by using cast(multiset(
So never mind.
Thank You.
Rama. -
How to Dump XML data into table
Hi All,
We have one schema on a server.
We have created the same schema with only table structures on another new server.
Now we got the data from the original schema as XML files corresponding to each table.
For Example, we have Employee table created newly on a new server. Now we have the XML file which has Employee data. We have to dump this XML data into new EMPLOYEE table.
We have to dump these XML files data into corresponding tables.
How can we achieve this?
Please help me..
Thanks in advanceLook at this example:
Assume you have the following XML in a tempxml table (tempxml could be an external table):
create table tempxml (xml xmltype);
insert into tempxml values (xmltype(
'<?xml version="1.0"?>
<ROWSET>
<ROW>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<MGR>7902</MGR>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>20-FEB-81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>22-FEB-81</HIREDATE>
<SAL>1250</SAL>
<COMM>500</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7566</EMPNO>
<ENAME>JONES</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>02-APR-81</HIREDATE>
<SAL>2975</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7654</EMPNO>
<ENAME>MARTIN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>28-SEP-81</HIREDATE>
<SAL>1250</SAL>
<COMM>1400</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7698</EMPNO>
<ENAME>BLAKE</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>01-MAY-81</HIREDATE>
<SAL>2850</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7782</EMPNO>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>09-JUN-81</HIREDATE>
<SAL>2450</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7788</EMPNO>
<ENAME>SCOTT</ENAME>
<JOB>ANALYST</JOB>
<MGR>7566</MGR>
<HIREDATE>19-APR-87</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7839</EMPNO>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
<HIREDATE>17-NOV-81</HIREDATE>
<SAL>5000</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
<ROW>
<EMPNO>7844</EMPNO>
<ENAME>TURNER</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>08-SEP-81</HIREDATE>
<SAL>1500</SAL>
<COMM>0</COMM>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7876</EMPNO>
<ENAME>ADAMS</ENAME>
<JOB>CLERK</JOB>
<MGR>7788</MGR>
<HIREDATE>23-MAY-87</HIREDATE>
<SAL>1100</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7900</EMPNO>
<ENAME>JAMES</ENAME>
<JOB>CLERK</JOB>
<MGR>7698</MGR>
<HIREDATE>03-DEC-81</HIREDATE>
<SAL>950</SAL>
<DEPTNO>30</DEPTNO>
</ROW>
<ROW>
<EMPNO>7902</EMPNO>
<ENAME>FORD</ENAME>
<JOB>ANALYST</JOB>
<MGR>7566</MGR>
<HIREDATE>03-DEC-81</HIREDATE>
<SAL>3000</SAL>
<DEPTNO>20</DEPTNO>
</ROW>
<ROW>
<EMPNO>7934</EMPNO>
<ENAME>MILLER</ENAME>
<JOB>CLERK</JOB>
<MGR>7782</MGR>
<HIREDATE>23-JAN-82</HIREDATE>
<SAL>1300</SAL>
<DEPTNO>10</DEPTNO>
</ROW>
</ROWSET>'));You can insert into an empty EMP2 table this way:
SQL> insert into emp2
2 select myemp.empno, myemp.ename, myemp.job, myemp.mgr,
3 to_date(myemp.hiredate,'dd-mon-yy'), myemp.sal,
4 myemp.comm, myemp.deptno
5 from tempxml x, xmltable('/ROWSET/ROW'
6 PASSING x.xml
7 COLUMNS
8 empno number PATH '/ROW/EMPNO',
9 ename varchar2(10) PATH '/ROW/ENAME',
10 job varchar2(9) PATH '/ROW/JOB',
11 mgr number PATH '/ROW/MGR',
12 hiredate varchar2(9) PATH '/ROW/HIREDATE',
13 sal number PATH '/ROW/SAL',
14 comm number PATH '/ROW/COMM',
15 deptno number PATH '/ROW/DEPTNO'
16 ) myemp;
14 rows created.
SQL> select * from emp2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.Max
http://oracleitalia.wordpress.com -
Hi all,
I have an XML file (emp.xml) with below data:
- <root>
- <row>
<lastname>steve</lastname>
<Age>30</Age>
</row>
- <row>
<lastname>Paul</lastname>
<Age>26</Age>
</row>
</root>
I'd like to create a stored procedure to store the xml data into EMP table.
EMP
LastName Age
Steve 30
Paul 26
I tried to look all the related threads in this forum, but couldn't find the right thread. Any help is greatly appreciated. ThanksWith
SQL> select * from xmltable('root/row' passing xmltype('<root>
<row>
<lastname>steve</lastname>
<Age>30</Age>
</row>
<row>
<lastname>Paul</lastname>
<Age>26</Age>
</row>
</root>') columns lastname path 'lastname',
Age path 'Age')
LASTNAME AGE
steve 30
Paul 26 you can now simple do a
insert into emp as select .... -
Xml Data into Table Within an Oracle Database
With no oracle or database background, I have been tasked to figure out how to analyze reading values within xml files. I initially started by writing c# code to read through the xml files, pull out the values I need and summarize the results. Unfortunately, this took atleast 5 hours to open all the xml files and summarize the results for a small portion of EndPointChannelId's and xml files. I decided to store all the reading values within the xml files into a table so I can use SQL queries to do the analysis instead of having to process through all the files each time. Using the same c# code as before, I have used insert and update sql statements to insert the reading values into a table. To my dismay, it takes about 3 and a half hours to import 1 file where there is 20 files a day :S. There are over 19,000 ChannelID's per file. I am currently using SQL Developer to view the data and have noticed XML Schemas and XML DB Repository but am not sure if that would be the best approach to my problem. I need to increase the efficiency of the import process but I am having difficulties trying to figure out how to go about it. Do you have any suggestions on where I should go from here? What is the most efficient way you have used to import xml files into a table structure. I would greatly appreciate any ideas!
Below is a portion of the xml file that I am working with.
- <Channel ReadingsInPulse="false" IsRegister="false" IsReadingDecoded="true" MarketType="Electric" IntervalLength="60">
<ChannelID EndPointChannelID="57432:1" />
- <ContiguousIntervalSets>
- <ContiguousIntervalSet NumberOfReadings="6">
<TimePeriod EndRead="22467.80" EndTime="2013-05-09T13:00:00Z" StartTime="2013-05-09T07:00:00Z" />
- <Readings>
<Reading Value="0.31" />
<Reading Value="0.4" />
<Reading Value="0.16" />
<Reading Value="0.32" />
<Reading Value="0.09" />
<Reading Value="0.35" />
</Readings>
</ContiguousIntervalSet>
</ContiguousIntervalSets>
</Channel>Hi,
Welcome to the forums,
what i understand from your Post, You want to read/analyze some value from xml files. and for this you want to import it in database and then perform some Query on that file for easy work.
you can choose the External table concept for reading/ Query those files
check this link may it help you
Creation of External table by using XML files.
http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables013.htm -
How to Store an XML Data into Table?
Hi All,
My Requirement is "I Have an XML File (or) XML Data as CLOB, now I should decode this XML Data and find the equivalent data for columns in a table and then store that in a relational table",
Would be greatful if any one can provide me a feasible solution (or) good link where I can get this information with examples.
Thanks in advance,
Sunil NOr,
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.03
satyaki>
satyaki>
satyaki>drop table dump_tab;
Table dropped.
Elapsed: 00:00:01.08
satyaki>
satyaki>create table dump_tab
2 (
3 raw_xml clob
4 );
Table created.
Elapsed: 00:00:00.00
satyaki>
satyaki>
satyaki>desc dump_tab;
Name Null? Type
RAW_XML CLOB
satyaki>
satyaki>
satyaki>insert into dump_tab
2 select yy.rxml
3 from (
4 select (' <data>
5 <var name="document">
6 <string>Sales Order</string>
7 </var>
8 <var name="results">
9 <recordset rowcount="2">
10 <field name="sales_num">
11 <string>12345</string>
12 <string>60192</string>
13 </field>
14 <field name="ord_qty">
15 <string>10</string>
16 <string>50</string>
17 </field>
18 </recordset>
19 </var>
20 </data>'
21 ) rxml from dual
22 ) yy;
1 row created.
Elapsed: 00:00:00.00
satyaki>
satyaki>commit;
Commit complete.
Elapsed: 00:00:00.00
satyaki>
satyaki>create table results
2 (
3 serial_no number(5),
4 sales_num number(7),
5 ord_qty number(10)
6 );
Table created.
Elapsed: 00:00:00.00
satyaki>
satyaki>desc results;
Name Null? Type
SERIAL_NO NUMBER(5)
SALES_NUM NUMBER(7)
ORD_QTY NUMBER(10)
satyaki>
satyaki>select * from dump_tab;
RAW_XML
<data>
<var name="document">
<string>Sales Order</string>
</var>
<var name="results">
<recordset rowcount="2">
<field name="sales_num">
<string>12345</string>
<string>60192</string>
</field>
<field name="ord_qty">
RAW_XML
<string>10</string>
<string>50</string>
</field>
</recordset>
</var>
</data>
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>ed
Wrote file afiedt.buf
1 insert into results(serial_no,sales_num,ord_qty)
2 with t
3 as (
4 select xmltype(raw_xml) xml from dump_tab
5 ),
6 t1 as (select rownum rn, t1.column_value.extract('*/text()') sales_num from t t, table(xmlsequence(t.xml.extract('//field[@name="sales_num"]/string'))) t1),
7 t2 as (select rownum rn, t2.column_value.extract('*/text()') ord_qty from t t, table(xmlsequence(t.xml.extract('//field[@name="ord_qty"]/string'))) t2)
8 select t1.rn x,
9 to_number(regexp_replace(xmlelement("e",sales_num).getstringval(),'<(|/)e>','')) sales_num
10 to_number(regexp_replace(xmlelement("d",ord_qty).getstringval(),'<(|/)d>','')) ord_qty
11 from t1,t2
12* where t1.rn = t2.rn
satyaki>/
2 rows created.
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from results;
SERIAL_NO SALES_NUM ORD_QTY
1 12345 10
2 60192 50
Elapsed: 00:00:00.00
satyaki>Regards.
Satyaki De. -
When I try to load data following the document
http://metalink.oracle.com/metalink/plsql/ml2_documents.showNOT?p_id=121405.1&p_showHeader=1&p_showHelp=0
I get these messages:
SQL> exec loadxml;
ERROR:
ORA-06550: line 1, column 29:
PLS-00553: character set name is not recognized
ORA-06550: line 0, column 0:
PL/SQL: Compilation unit analysis terminated
I have created example.xml file from the example shown in the above document, as well as procedule loaxml from the document. I would appreciate if you could point out what could be wrong. How do I verify that jserver and XML-SQL (XSU) Utility is installed?I did some basic testing. I logged in as SYS-user.
SELECT directory_name,directory_path
FROM all_directories where directory_name like 'XML%';
gives the directory in db-server ok:
DIRECTORY_NAME ...... DIRECTORY_PATH
XML_FILES ................... D:\OWB_Files
If i run this:
SELECT DBMS_LOB.getLength( BFileName('XML_FILES','asi.xml'))
AS length FROM dual;
i get this:
ERROR at line 1:
ORA-22288: file or LOB operation GETLENGTH failed
The system cannot find the file specified.ORA-06512: at "SYS.DBMS_LOB", line 566
I made a copy of one xml-file to name asi.xml and grated to USER all priviledges in Windows Explorer. I also run this in SQL*Plus: grant all on directory XML_FILES to public;
If i made a typo to directory name 'XML_FILES' -> 'XML_zzzFILES' i get different error message: ORA-22285: non-existent directory or file for GETLENGTH operation.
So, directory is okay? But all the files are some in the shadows? Once again - run out of ideas. -
Error while inserting xml data into table
Hello
I am running thid stored procedure and this compiles correctly , but when I try to execute it gives me a error, I have been trying this form the past 3 days , could anyone please help me ASAP
SQL> CREATE OR REPLACE PROCEDURE loadxml12 AS
2 fil BFILE;
3 buffer RAW(32767);
4 len INTEGER;
5 insrow INTEGER;
6 BEGIN
7 SELECT f_lob INTO fil FROM xml_temp12 WHERE key = 1;
8 DBMS_LOB.FILEOPEN(fil,DBMS_LOB.FILE_READONLY);
9 len := DBMS_LOB.GETLENGTH(fil);
10 DBMS_LOB.READ(fil,len,1,buffer);
11 xmlgen.resetOptions;
12 insrow := xmlgen.insertXML('xml_doc',UTL_RAW.CAST_TO_VARCHAR2(buffer));
13 DBMS_OUTPUT.PUT_LINE(insrow);
14 IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
15 DBMS_LOB.FILECLOSE(fil);
16 END IF;
17 EXCEPTION
18 WHEN OTHERS THEN
19 DBMS_OUTPUT.PUT_LINE('In Exception');
20 DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE));
21 IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
22 DBMS_LOB.FILECLOSE(fil);
23 END IF;
24 end;
25 /
Procedure created.
SQL> exec loadxml12
In Exception
BEGIN loadxml12; END;
ERROR at line 1:
ORA-20000: ORU-10028: line length overflow, limit of 255 bytes per line
ORA-06512: at "SYS.DBMS_OUTPUT", line 99
ORA-06512: at "SYS.DBMS_OUTPUT", line 65
ORA-06512: at "CARCLUB_RW2.LOADXML12", line 20
ORA-06512: at line 1
nullCould you explain what your procedure does, please. I also tried to compile it but always got error message:
PL/SQL: SQL Statement ignored
PLS-00385: type mismatch found at 'FIL' in SELECT...INTO
statement
SQL> CREATE OR REPLACE PROCEDURE loadxml12 AS
2 fil BFILE;
3 buffer RAW(32767);
4 len INTEGER;
5 insrow INTEGER;
6 BEGIN
7 SELECT f_lob INTO fil FROM xml_temp12 WHERE key = 1;
8 DBMS_LOB.FILEOPEN(fil,DBMS_LOB.FILE_READONLY);
9 len := DBMS_LOB.GETLENGTH(fil);
10 DBMS_LOB.READ(fil,len,1,buffer);
11 xmlgen.resetOptions;
12 insrow := xmlgen.insertXML('xml_doc',UTL_RAW.CAST_TO_VARCHAR2(buffer));
13 DBMS_OUTPUT.PUT_LINE(insrow);
14 IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
15 DBMS_LOB.FILECLOSE(fil);
16 END IF;
17 EXCEPTION
18 WHEN OTHERS THEN
19 DBMS_OUTPUT.PUT_LINE('In Exception');
20 DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE));
21 IF DBMS_LOB.FILEISOPEN(fil) = 1 THEN
22 DBMS_LOB.FILECLOSE(fil);
23 END IF;
24 end;
25 /
Bober
null -
Error occured while inserting XML file data into table.
Hello,
I m trying to load xml data into table by following code.but getting below error
Error at line 1
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00222: error received from SAX callback function
ORA-06512: at "SYS.DBMS_XMLSTORE", line 78
ORA-06512: at line 21
DECLARE
xmldoc clob;
insCtx DBMS_XMLStore.ctxType;
dname varchar2(20) := 'MDIR';
rows number;
BEGIN
xmldoc := dbms_xslprocessor.read2clob(dname, 'try_xm3.xml');
insCtx := DBMS_XMLStore.newContext('try1');
dbms_output.put_line('1');
DBMS_XMLStore.setRowTag(insCtx, 'cajas');
rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
commit;
dbms_output.put_line('INSERT DONE '||TO_CHAR(rows));
DBMS_XMLStore.closeContext(insCtx);
END;
<?xml version="1.0" encoding="utf-8"?>
<cajas xmlns="PBcion.Caja" fec="2011-03-02T14:20:14" codDeleg="093">
<caj codPrev="80001223" fechaInicio="2011-03-02" fec="2011-09-02" couta="01" idPerio="1" caj="32"></caj>
</cajas>can you please look into this?
I m using oracle 10gSQL> create table try1
2 (
3 codPrev number,
4 fechaInicio varchar2(25),
5 fec varchar2(25),
6 couta number,
7 idPerio number,
8 caj number
9 );
Table created
SQL>
SQL> insert into try1 (codprev, fechainicio, fec, couta, idperio, caj)
2 select x.codprev, x.fechainicio, x.fec, x.couta, x.idperio, x.caj
3 from xmltable(
4 xmlnamespaces(default 'PBcion.Caja')
5 , '/cajas/caj'
6 passing xmltype(bfilename('TEST_DIR','try_xm3.xml'), nls_charset_id('AL32UTF8'))
7 columns codPrev number path '@codPrev'
8 , fechaInicio varchar2(25) path '@fechaInicio'
9 , fec varchar2(25) path '@fec'
10 , couta number path '@couta'
11 , idPerio number path '@idPerio'
12 , caj number path '@caj'
13 ) x
14 ;
1 row inserted
SQL> select * from try1;
CODPREV FECHAINICIO FEC COUTA IDPERIO CAJ
80001223 2011-03-02 2011-09-02 1 1 32
Since the two date attributes are coming in the W3C's xs:date format, you can directly define the corresponding columns as DATE and use a DATE projection in XMLTable :
SQL> alter table try1 modify (fechainicio date);
Table altered
SQL> alter table try1 modify (fec date);
Table altered
SQL>
SQL> insert into try1 (codprev, fechainicio, fec, couta, idperio, caj)
2 select x.codprev, x.fechainicio, x.fec, x.couta, x.idperio, x.caj
3 from xmltable(
4 xmlnamespaces(default 'PBcion.Caja')
5 , '/cajas/caj'
6 passing xmltype(bfilename('TEST_DIR','try_xm3.xml'), nls_charset_id('AL32UTF8'))
7 columns codPrev number path '@codPrev'
8 , fechaInicio date path '@fechaInicio'
9 , fec date path '@fec'
10 , couta number path '@couta'
11 , idPerio number path '@idPerio'
12 , caj number path '@caj'
13 ) x
14 ;
1 row inserted
SQL> select * from try1;
CODPREV FECHAINICIO FEC COUTA IDPERIO CAJ
80001223 02/03/2011 02/09/2011 1 1 32 -
Hi Friends,
See the followong code which converts xml data into itab.
*& Report ZTEST_XML1 *
REPORT ZTEST_XML1 .
*PURPOSE: This program transfers XML data into SAP internal table format
*The nodes in DOM can be stored as fields in SAP Internal table
type pool definitions
TYPE-POOLS: ixml. "iXML Library Types
type definitions
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
*t_xml_line
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string. " String to hold filename
data: begin of i_final occurs 0,
pnumber(20),
pname(50),
pdes(70),
end of i_final.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'C:\product.xml'.
Validation of XML file: Only DTD included in XML document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
start of selection
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
Wrap the table containing the file into a stream.
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Creating a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val = 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) <> 0.
IF l_parser->num_errors( ) <> 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
text
<--P_L_XML_TABLE_SIZE text
<--P_L_XML_TABLE text
FORM get_xml_table CHANGING p_l_xml_table_size
p_l_xml_table.
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
Upload file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. " get_xml_table
*& Form process_dom
text
-->P_L_DOCUMENT text
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE:/.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL.
EXIT.
ENDIF.
Create a node iterator
iterator = node->create_iterator( ).
Get current node
node = iterator->get_next( ).
Loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
Advance to next node
node = iterator->get_next( ).
ENDWHILE.
*delete adjacent duplicates from i_final.
*loop at i_final.
*write:/ i_final-pnumber,i_final-pname,i_final-pdes.
*endloop.
*if not i_final[] is initial.
*modify ztestproduct from table i_final.
*endif.
ENDFORM. " process_dom
in the above code at line no: 268 there is a method:
value = node->get_value( ).in which actual data from XML file is coming.
So the varibale "Value" contains the data.
see line no: 270:
WRITE: AT indent value COLOR COL_GROUP INVERSE.
what ever values i am getting here i want to append to a Internal table ...
Can any body tell me how to do that?
i am sure of reward points.Hai Ravi
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[].
Regards
Sreeni -
Please recommend if we have options to read xml file and insert data into table without a temporary table.
DECLARE @data XML;
SET @data =N'<Root>
<List RecordID="946236" />
<List RecordID="946237" />
<List RecordID="946238" />
<List RecordID="946239" />
<List RecordID="946240" />
</Root>'
INSERT INTO t (id) SELECT T.customer.value('@RecordID', 'INT') AS id
FROM @data.nodes('Root/List')
AS T(customer);
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Loading XML Data into Relational Table
Hello,
I receive an XML file generated from another tool (on Windows), I am trying to create a Linux shell script that will gather the needed XML file from my Linux database server, then have Oracle use this file to load the XML data into a relational table. This activity & data will be needed on an ongoing basis.
I have tried this two ways. First, I loaded the XML document into the database and tried to extract the data directly from the document, but that is not working. Now I want to try to read the data directly from the file on the server via select, however I am not getting any data returned. In the Select statement below, I am simply trying to query the data to see what is returned for my testing.
Create Table ci_results_table (transactionID Varchar2(100), //transactionID should be PrimaryKey but was getting NULL value errors during insert test, so removed PK
message Varchar2(200),
ci Varchar2(50),
processeddate xmltype,
status Varchar2(50),
sourcefile VarChar2(100));
select x.*
from XMLTable(
'TSPLoadResults/Results'
PASSING xmltype(bfilename('CMDB_DEVADHOCRESULTS_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('AL32UTF8'))
COLUMNS
transactionID Varchar2(100) PATH 'TransactionID',
Result XMLType PATH 'Result',
Message Varchar2(200) PATH 'Message',
PrimaryKey Varchar2(50) PATH 'PrimaryKey',
ProcessedDate date PATH 'ProcessedDate',
Status Varchar2(50) PATH 'Status',
SourceFile VarChar2(100) PATH 'SourceFileName'
) x
Eventually I will need to build on this to limit the data returned to those records where SourceFileName is like 'HPDS%' and insert what is returned in to the ci_results_table. Attached is a sample Results XML file I am trying to load, It is named "ResultsTransformedtoUnix" because I used dos2Unix to convert it to Unix which may be right or wrong. (The output file I send out has to be transformed to DOS format before the other application can read it). Original file (before Unix conversion) named in script is also attached.
Please help. Thank you!Hi,
I see some wrong things in your query.
1) The obvious one, explaining why you're not getting any data : there's a typo in the XQuery expression, it's "Result" not "Results"
2) ProcessedDate cannot be extracted as a date (at least not directly) since it actually represents a timestamp, use TIMESTAMP WITH TIME ZONE datatype and cast back to DATE in the SELECT clause
3) transactionID is an attribute, it must be accessed with '@' (or 'attribute::' axis)
4) If the file encoding is truly ISO-8859-1 as the prolog suggests, then do not use AL32UTF8 but the corresponding charset name : WE8ISO8859P1
Here's the working query :
select x.transactionID
, x.Message
, x.Primarykey
, cast(x.ProcessedDate as date) ProcessDate
, x.Status
, x.SourceFile
from XMLTable(
'/TSPLoadResults/Result'
PASSING xmltype(bfilename('XML_DIR','LoadResults-HP_146.results.xml'), nls_charset_id('WE8ISO8859P1'))
COLUMNS
transactionID Varchar2(100) PATH '@transactionID',
Message Varchar2(200) PATH 'Message',
PrimaryKey Varchar2(50) PATH 'PrimaryKey',
ProcessedDate timestamp with time zone PATH 'ProcessedDate',
Status Varchar2(50) PATH 'Status',
SourceFile VarChar2(100) PATH 'SourceFileName'
) x
Using this query directly over the file will only perform decently (for large files) on 11.2.0.4 and onwards.
On prior versions, first load the file in a (temporary) XMLType column with Binary XML storage and SELECT from there.
because I used dos2Unix to convert it to Unix which may be right or wrong.
This conversion shouldn't be necessary. -
How to Convert internal table data into xml and xml data into internal tab
Hi Guys,
I have a requirement that i have to convert the internal table data into xml format and viceversa . for my requirement i came to know that i have to use Transformations concept. i done the converting the data from internal table into xml data by using standard Tranformations. My Question is
1) Can i use same Transformation to convert the xml data into abap internal table. if it is possible then how ???
2) Is it possible using the standard Transformation or I have to go for XSLT approach
Please help me out from this guys,
Thanks and Regards
KotiHi Koti,
This is possible. There is a link. With the help of this link you can convert ABAP data to XML and vice versa.
Link: http://www.heidoc.net/joomla/index.php?option=com_content&view=article&id=15:sapxslt&catid=22:sap-xslt&Itemid=31 -
How to store XML data into Oracle Table
I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
<Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
at testInsert.main(testInsert.java:8)
Here is my xml file:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<DNAME>ACCOUNTING</DNAME>
<LOC>NEW YORK</LOC>
</ROW>
<ROW num="2">
<DEPTNO>20</DEPTNO>
<DNAME>RESEARCH</DNAME>
<LOC>DALLAS</LOC>
</ROW>
<ROW num="3">
<DEPTNO>30</DEPTNO>
<DNAME>SALES</DNAME>
<LOC>CHICAGO</LOC>
</ROW>
<ROW num="4">
<DEPTNO>40</DEPTNO>
<DNAME>OPERATIONS</DNAME>
<LOC>BOSTON</LOC>
</ROW>
</ROWSET>
and here is structure of table:
Name Null? Type
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
and here is my Java Code:
import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert{
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
sav.insertXML(args[0]);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
return conn;
Could you help me ? Thanks !The problem is that you need to pass avalid URL , Document...
Please try this code instead:
import java.net.*;
import java.sql.*;
import java.io.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
URL url = createURL(args[0]);
sav.insertXML(url);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
return conn;
// Helper method to create a URL from a file name
static URL createURL(String fileName)
URL url = null;
try
url = new URL(fileName);
catch (MalformedURLException ex)
File f = new File(fileName);
try
String path = f.getAbsolutePath();
// This is a bunch of weird code that is required to
// make a valid URL on the Windows platform, due
// to inconsistencies in what getAbsolutePath returns.
String fs = System.getProperty("file.separator");
if (fs.length() == 1)
char sep = fs.charAt(0);
if (sep != '/')
path = path.replace(sep, '/');
if (path.charAt(0) != '/')
path = '/' + path;
path = "file://" + path;
url = new URL(path);
catch (MalformedURLException e)
System.out.println("Cannot create url for: " + fileName);
System.exit(0);
return url; -
Inporting XML data into a table
I have the followiing XML document
<?xml version="1.0" encoding="utf-8"?>
<agents count="1382">
<agent>
<name>Nancy Palmer</name>
<email>[email protected]</email>
<agentid>MLSL:00525350</agentid>
<officeid>58</officeid>
<website>http://www.nancypalmer.com</website>
<photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_8418_NANCY_PALMER_COLOR_HEAD_SHOT_HIGH_QUALITY_2011.jpg</photo>
<phone_direct>6504344313</phone_direct>
<phone_cell>6504920200</phone_cell>
<mod_time>2012-08-31T05:15:06.933</mod_time>
</agent>
<agent>
<name>Genella Williamson</name>
<email>[email protected]</email>
<agentid>MLSL:00755754</agentid>
<officeid>58</officeid>
<website>http://www.apr.com/genella</website>
<photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_8426_genella.jpg</photo>
<phone_direct>6504344319</phone_direct>
<phone_cell>6507870839</phone_cell>
<mod_time>2010-10-30T15:15:07.603</mod_time>
</agent>
<agent>
<name>Diana Langley</name>
<email>[email protected]</email>
<agentid>MLSL:01256202,SFAR:805608</agentid>
<officeid>50</officeid>
<website>http://www.apr.com/DLangley</website>
<photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_7848_dlangley.jpg</photo>
<phone_direct/>
<phone_cell/>
<mod_time>2011-06-06T05:15:06.587</mod_time>
</agent>
</agents>
I want to load it to the following table
SQL> desc apr_agent
Name Null? Type
NAME VARCHAR2(100)
EMAIL VARCHAR2(100)
OFFICEID VARCHAR2(50)
WEBSITE VARCHAR2(1000)
PHOTO VARCHAR2(1000)
PHONE_DIRECT VARCHAR2(100)
PHONE_CELL VARCHAR2(100)
MOD_DATE VARCHAR2(100)
SQL>
So I created a directory
create or replace directory APR_STG as '/opt/smarteragent/procdata/APR';
and I created the following insert statement
INSERT INTO apr_agent
(NAME, email, officeid, website, photo, phone_direct, phone_cell, mod_date)
WITH T AS (SELECT XMLTYPE(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8')) xmlcol FROM dual)
SELECT EXTRACTVALUE(VALUE(x),'/ROW/name') NAME,
EXTRACTVALUE(VALUE(x),'/ROW/email') email,
EXTRACTVALUE(VALUE(x),'ROW/officeid') officeid,
EXTRACTVALUE(VALUE(x),'ROW/website') website,
EXTRACTVALUE(VALUE(x),'ROW/photo') photo,
EXTRACTVALUE(VALUE(x),'ROW/phone_direct') phone_direct,
EXTRACTVALUE(VALUE(x),'ROW/phone_cell') phone_cell,
EXTRACTVALUE(VALUE(x),'ROW/mod_time') mod_date
FROM T,TABLE(XMLSEQUENCE(EXTRACT(T.xmlcol,'/ROWSET/ROW'))) x;
I am currently getting now rows inserted. Not sure why?
Any help would be greatly appreciated.Well, if you were to run the SELECT statement alone (from WITH on down), you would see that it is returning 0 rows. After some head-scratching and searching you would come to realize it is because your XPaths are not finding any data in the XML. In your XPaths, you are looking for a root node of ROWSET with a child of ROW. In the XML, the root node is agents and the child is agent. Assuming you are on 10.2 or later, your SELECT statement itself could be written as
SELECT NAME, email,
officeid, website,
photo, phone_direct,
phone_cell, mod_date
FROM XMLTable('/agents/agent'
PASSING XMLType(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8'))
COLUMNS
NAME VARCHAR2(100) PATH 'name',
email VARCHAR2(100) PATH 'email',
officeid VARCHAR2(50) PATH 'officeid',
website VARCHAR2(1000) PATH 'website',
photo VARCHAR2(1000) PATH 'photo',
phone_direct VARCHAR2(100) PATH 'phone_direct',
phone_cell VARCHAR2(100) PATH 'phone_cell',
mod_date VARCHAR2(100) PATH 'mod_time');and then you could just append that to your INSERT so you have something like
INSERT INTO apr_agent
(NAME, email, officeid, website, photo, phone_direct, phone_cell, mod_date)
SELECT NAME, email,....If the count of 1382 is to be believed, then you may start wondering why your INSERT is taking so long to process. Performance will depend upon many factors.
If you are on 11g (any of them), then you have an option to improve performance over 10.2 and earlier versions. You simply create a table, it could even be a Global Temporary Table that looks something like
create table TEMP_XML (XML_DATA xmltype)
xmltype column XML_DATA store as securefile binary xml;(if on 11.2.0.2 or later, you only need)
create table TEMP_XML (XML_DATA xmltype);Then you insert the XML data into it via
INSERT INTO TEMP_XML VALUES XMLType(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8')));and change the above SELECT statement to read from that table instead, such as
SELECT NAME, email,
officeid, website,
photo, phone_direct,
phone_cell, mod_date
FROM TEMP_XML tx
XMLTable('/agents/agent'
PASSING tx.xml_data
...And then you'll be done with that task.
Note: Only the first SQL statement was verified, the rest should be valid but have not been executed/verified.
Maybe you are looking for
-
Link Item Style to open a PDF hangs if opened in IE in 30 seconds
Hi, I am using Jdeveloper version 9.0.3. I have a page in which, I have an advanced table, in which there is a column, with item style - link. On the link item there is a PPR event and it should open a PDF file, residing on the server. I am using jav
-
No error, just doesn't transfer purchases.
I keep trying to transfer my purchases from my iPad to my computer for backup and the iPad says "Sync in Progress" and iTunes shows the names of the items and acts like it is working through them but nothing actually transfers. Other than the items n
-
How to set number of rows in filters?
Hi, we need to set another number of rows which is displayed in filters on bex or web template? Thanks for advice
-
I need fm transmit for my nokia e72 :(
how can i get fm transmit for my nokia e72??
-
Can't send pictures with my tour? No MMS option, how do I get around this!
I can't stand that I can't send a picture message, I dont understand why this phone would only have the option to email a picture. I want to be able to text a picture, even the oldest of phones have this option.. disliking telus for this one! So is t