transform xml into slow rational table
my xml file looks like this
has about 3000 'Sidonie' (tag < row >)
and is really simple
-------------------------------------
<? XML version = "1.0" encoding = "ISO-8859-1? >
< adapt_xml >
< row >
< Field1 > 34093 < / field1 >
< Field2 > < / Field2 >
...
< field50 > 34 < / field50 >
< liste_photos >
adf_photo_2.jpg < picture > < / photo >
adf_photo_7.jpg < picture > < / photo >
adf_photo_4.jpg < picture > < / photo >
....
< / liste_photos >
...
< / row
< row >
< Field1 > 34093 < / field1 >
< Field2 > < / Field2 >
...
< field50 > 34 < / field50 >
< liste_photos >
adf_photo_2.jpg < picture > < / photo >
adf_photo_7.jpg < picture > < / photo >
adf_photo_4.jpg < picture > < / photo >
....
< / liste_photos >
...
< / row >
< row >
< Field1 > 34093 < / field1 >
< Field2 > < / Field2 >
...
< field50 > 34 < / field50 >
< liste_photos >
adf_photo_2.jpg < picture > < / photo >
adf_photo_7.jpg < picture > < / photo >
adf_photo_4.jpg < picture > < / photo >
....
< / liste_photos >
...
< / row >
< row >
< Field1 > 34093 < / field1 >
< Field2 > < / Field2 >
...
< field50 > 34 < / field50 >
< liste_photos >
adf_photo_2.jpg < picture > < / photo >
adf_photo_7.jpg < picture > < / photo >
adf_photo_4.jpg < picture > < / photo >
....
< / liste_photos >
...
< / row >
< row >
< Field1 > 34093 < / field1 >
< Field2 > < / Field2 >
...
< field50 > 34 < / field50 >
< liste_photos >
adf_photo_2.jpg < picture > < / photo >
adf_photo_7.jpg < picture > < / photo >
adf_photo_4.jpg < picture > < / photo >
....
< / liste_photos >
...
< / row >
...
< / adapt_xml >
-------------------------------------
the XML is stored in an xml table in Oracle (Version 11.2...)
I have to extract the values a store in a relational table
to do this, I make the following declarations
It's fast
SELECT
x1.field1,
x 1. Field2,
x1.field3,
....
x 1. Field50
OF tmp_xml.
XMLTable)
' / / row '
by the way OBJECT_VALUE
columns
path of Field1 "Field1."
path of Field2 'Field2 ',.
field3 path "field3"
...
Field50 path 'field50 '.
) x 1
It's really slow
SELECT
x1.field1,
x 1. Field2,
x1.field3,
....
x 1. Field50,
x 1 .photo_1,
x 1 .photo_2,
x 1 .photo_3,
x 1 .photo_4,
x 1 .photo_5,
x 1 .photo_6,
x 1 .photo_7,
x 1 .photo_8,
x 1 .photo_9,
x 1 .photo_10,
x 1 .photo_11,
x 1 .photo_12,
x 1 .photo_13
OF tmp_xml.
XMLTable)
' / / row '
by the way OBJECT_VALUE
columns
path of Field1 "Field1."
path of Field2 'Field2 ',.
field3 path "field3"
...
Field50 path "field50."
picture_1 path "liste_photos/photo [1]."
photo_2 path "liste_photos/photo [2]."
picture_3 path "liste_photos/photo [3]."
photo_4 path "liste_photos/photo [4]."
photo_5 path "liste_photos/photo [5]."
photo_6 path "liste_photos/photo [6]."
photo_7 path "liste_photos/photo [7]."
photo_8 path "liste_photos/photo [8]."
photo_9 path "liste_photos/photo [9]."
photo_10 path "liste_photos/photo [10]."
photo_11 path "liste_photos/photo [11]."
photo_12 path "liste_photos/photo [13]."
photo_13 path "liste_photos/photo [13].
) x 1
It's slow as well
SELECT
x1.field1,
x 1. Field2,
x1.field3,
....
x 1. Field50,
x 1 .liste_photos,
OF tmp_xml.
XMLTable)
' / / row '
by the way OBJECT_VALUE
columns
path of Field1 "Field1."
path of Field2 'Field2 ',.
field3 path "field3"
...
Field50 path "field50."
path liste_photos xmltype "liste_photos."
) x 1
I tried to cash some xmltype index
but without success
the selection of the Field1... field50 is fast
But if I select the photo list the performance is down
Thank you
Martin
Finally, it works
It has been a long road to success
in the end, it was an oracle bug
I opened a SR with Oracle in September
After some time without any progress in the SR (no reply) I let it worsen the SR.
not much happened until 24 x 7 climbing
Since I guess it was in December (3 months later) they are really working on my SR and they had the same problems that I have
in the end, that they discovered that it was because of the UTF8 character set
the bug is now fixed in paragraph 12.2 and I got a patch stop
If someone is interested in the patch
|
|
Tags: Database
Similar Questions
-
Loading XML into the relational Table data
Hello
I get a generated XML file to other tools (Windows), I am trying to create a Linux shell script that will gather the necessary XML file to my Linux server, then ask Oracle to use this file to load the XML data into a relational table. This activity and the data will be needed on an ongoing basis.
I tried two ways. First, I loaded the XML document into the database and tried to extract the data directly from the document, but it does not work. Now I want to try to read the data directly from the file on the server through select, however I don't get all the returned data. In the Select statement below, I am trying to query the data to see what is returned for my tests.
Create Table ci_results_table (transactionID Varchar2 (100), //transactionID should be PrimaryKey but became errors in test of insert, PK so deleted NULL value)
message Varchar2 (200),
This Varchar2 (50).
XMLType of the ProcessedDate,
status Varchar2 (50).
sourceFile VarChar2 (100));
Select x.*
from XMLTable)
' TSPLoadResults/results '.
PASSAGE xmltype (bfilename('CMDB_DEVADHOCRESULTS_DIR','LoadResults-HP_146.results.xml'), nls_charset_id ('AL32UTF8'))
COLUMNS
transactionID PATH Varchar2 (100) 'TransactionID '.
Result XMLType PATH 'result ',.
Message Varchar2 (200) PATH "Message."
PrimaryKey Varchar2 (50) PATH "PrimaryKey"
Date of ProcessedDate path "ProcessedDate."
Status Varchar2 (50) PATH "Status."
SourceFile VarChar2 (100) PATH "SourceFileName.
) x
;
Eventually, I'll have to build on that to limit the returned data to records where SourceFileName is like '% PA' and insert what is returned in to the ci_results_table. Attached is an example of the XML results file I am trying to load, it is named "ResultsTransformedtoUnix" because I used dos2Unix to convert Unix which can be good or bad. (I send the output file must be converted to the format BACK until the other application can read). Original (before converting Unix) file named in the script is also attached.
Help, please. Thank you!
Hello
I see some bad things in your query.
(1) obvious one, explaining why you get all the data: there is a typing error in the XQuery expression, there 'result' not'slead.
(2) ProcessedDate can be extracted as a date (at least not directly) because it actually represents a timestamp, use the TIMESTAMP WITH time ZONE HOURS and cast back to DATE data type in the SELECT clause
(3) transactionID is an attribute, it must be accessible with ' @' (or ' attribute:' axis)
(4) if the encoding of file really is ISO-8859-1 as suggested in the prologue, then do not use AL32UTF8 but the name of the corresponding character set: WE8ISO8859P1
Here is the query to work:
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 ;
Directly on the file using this query will only be decently (for large files) on 11.2.0.4 and beyond.
On older versions, first load the file into a (temporary) XMLType column with binary XML storage and CHOOSE from there.
because I used dos2Unix to convert Unix which can be good or bad.
This conversion should not be necessary.
-
Insert data as XML into the Oracle Table
Hi all
I have a requirement where the data in XML format, and I need to insert into the Oracle Table. For example, I get XML data in the following format,
< results >
< row >
< BANK_ACCOUNT_ID > 10010 < / BANK_ACCOUNT_ID >
< BANK_ID > 300968 < / BANK_ID >
Vision operations < LEGAL_ENTITY > < / LEGAL_ENTITY >
< BANK_NAME > BofA < / BANK_NAME >
< BANK_ACCOUNT_NUM > 10271-17621-619 < / BANK_ACCOUNT_NUM >
< BANK_ACCOUNT_NAME > BofA-204 < / BANK_ACCOUNT_NAME >
< BRANCH_NAME > New York < / BRANCH_NAME >
USD < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 09 < / BALANCE_DATE >
< LEDGER_BALANCE > 432705900.56 < / LEDGER_BALANCE >
< / row >
< row >
< BANK_ACCOUNT_ID > 10091 < / BANK_ACCOUNT_ID >
< BANK_ID > 300984 < / BANK_ID >
Vision industries < LEGAL_ENTITY > < / LEGAL_ENTITY >
Barclay Bank < BANK_NAME > < / BANK_NAME >
< BANK_ACCOUNT_NUM > 70986798 < / BANK_ACCOUNT_NUM >
Bank Multi currency-626 < BANK_ACCOUNT_NAME > Barclays < / BANK_ACCOUNT_NAME >
Reading < BRANCH_NAME > < / BRANCH_NAME >
GBP < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 14 < / BALANCE_DATE >
< LEDGER_BALANCE > 24244085.24 < / LEDGER_BALANCE >
< / row >
< row >
< BANK_ACCOUNT_ID > 10127 < / BANK_ACCOUNT_ID >
< BANK_ID > 300968 < / BANK_ID >
< LEGAL_ENTITY > SSC U.S. 01 < / LEGAL_ENTITY >
< BANK_NAME > BofA < / BANK_NAME >
< BANK_ACCOUNT_NUM > 4898744 < / BANK_ACCOUNT_NUM >
< BANK_ACCOUNT_NAME > BofA SSC U.S. 02-7188 < / BANK_ACCOUNT_NAME >
< BRANCH_NAME > New York < / BRANCH_NAME >
USD < CURRENCY_CODE > < / CURRENCY_CODE >
< BALANCE_DATE > 2007 - 11 - 28 < / BALANCE_DATE >
< LEDGER_BALANCE > 10783815.28 < / LEDGER_BALANCE >
< / row >
< / results >
I like to write PLSQL code that will receive these data with XML tags and insert it into the Oracle Table. Is this possible with built-in XML features provided in the Oracle database?
Please Guide...
Kind regards
PriyankaBut the problem is the file XML is to have the details of the records if you carefully observed the XML file. But by using more high statement select I get output in the following format.
ORG_ID REQ_LINE PO_NUMBER EXPECTED_REC_QTY USER_NAME REQ_NUMBER
204204 1444714450 11 64446445 11 OPERATIONSOPERATIONSThe table has only one row, so you get a single row as output.
I'm surprised that you find useful examples showing how to divide the data into several lines.(1) create the table with the following option, it will optimize the performance of storage and query for large XML documents:
CREATE TABLE xxios_xml_data_test(xml_data XMLTYPE) XMLTYPE COLUMN xml_data STORE AS SECUREFILE BINARY XML ;
(2) interview table with:
SQL> select x.* 2 from xxios_xml_data_test t 3 , xmltable( 4 '/Results/Row' 5 passing t.xml_data 6 columns ORG_ID number path 'ORG_ID' 7 , REQ_NUMBER number path 'REQ_NUMBER' 8 , REQ_LINE number path 'REQ_LINE' 9 , PO_NUMBER number path 'PO_NUMBER' 10 , EXPECTED_REC_QTY number path 'EXPECTED_REC_QTY' 11 , USER_NAME varchar2(30) path 'USER_NAME' 12 ) x 13 ; ORG_ID REQ_NUMBER REQ_LINE PO_NUMBER EXPECTED_REC_QTY USER_NAME ---------- ---------- ---------- ---------- ---------------- ------------------------------ 204 14447 1 6444 1 OPERATIONS 204 14450 1 6445 1 OPERATIONS
-
Load the XML file into Oracle external Table
I load the data from the XML file into an intermediate table Oracle using external Tables.Let's say below, it is my XML file
< header >
< A_CNT > 10 < / A_CNT >
< E_CNT > 10 < / E_CNT >
< AF_CNT > 10 < / AF_CNT >
< / header >
< student >
<>students-details
< Student_info >
< Single_Info >
< ID > 18 / < ID >
New York < City > < / City >
< country > United States < / country >
< Name_lst >
< Student_name >
Samuel < name > < / name >
Paul < Last_name > < / Last_name >
< DOB > 19871208 < / DOB >
Aware of < RecordStatus > < / RecordStatus >
< / Student_name >
< Student_name >
Samuel < name > < / name >
Paul < Last_name > < / Last_name >
< DOB > 19871208 < / DOB >< TerminationDt > 20050812 < / TerminationDt >
History of < RecordStatus > < / RecordStatus >
< / Student_name >
< / Name_lst >
< Personal_Info >
<>men < / Type >
< 27 > < / Age >
< / Personal_Info >
< / Single_Info >
< / Student_info >< student - register >
class < A >
< info >
< detail >
< ID student > 18 < / student >
EE < major > < / Major >
< course-Grades >
< course > VLSI < / course >
< degree > 3.0 < / Grade >
< / course-Grades >
< course-Grades >
< course > nanotechnology < / course >
< degree > 4.0 < / Grade >
< / course-Grades >
< / details >
< detail >
< ID student > 18 < / student >
THIS < major > < / Major >
< / details >
< / info >
class < A >
< Student_Enrol >
<>students-details
< student >I load this XML data file into a single table using an external Table. Could someone help me please with coding.
Thank you
Reva
Could you please help me how to insert my XML content into that.
Same as before, try a plain old INSERT:
insert into xml_pecos
values)
XmlType (bfilename ('XML_DIR', "test.xml"), nls_charset_id ('AL32UTF8'))
);
But you'll probably hit the same limitation as with the binary XMLType table.
In this case, you can use FTP to load the file as a resource in the XML DB repository.
If the XML schema has been registered with the hierarchy enabled then the file will be automatically inserted into the table.
Could you post the exact statement that you used to save the scheme?
In the meantime, you can also read this article, I did a few years ago, it covers the XML DB features that may be useful here, including details on how to load the file via FTP:
https://odieweblog.WordPress.com/2011/11/23/Oracle-XML-DB-a-practical-example/
And documentation of the course: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb06stt.htm#ADXDB4672
-
My entry is a file. Because I don't have an ETL tool, I use a stored procedure to do ETL (which also gives me an advantage, I don't have to unload the target table to the join). So, I dump the contents of the file into a temporary table and use it in proc.
The query is like
Insert into < table1 target > (select fields and a transformation of < temporary table > where < key > target not in the table and < some joins with other tables in the database >)
Like that, I have four requests for four target tables.
The homes of the temporary table in the table target is very slow because the target a lot of index and RI. I can't let go & create index because the conditions of application does not give me this freedom.
My only option is to insert into a temporary table that is similar to the target, but without any clue/RI/PK and then dump in a file and then use SQL loader to load the file in the target table. It is relatively fast, but is a very heavy route for me.
Is there another way to bulk insert from one table to another table as SQL loader without using a file? Is anyway to bypass the update index operation without deleting the index?
My source will be almost 500,000 lines and target is to have 9 million lines.Posts like this are better to avoid.
Because
-You do not post a version
-You do not publish the SQL
-You do not publish the PLAN of EXPLAIN
It is your statement, the INSERT is to blame, but it can also be the SELECT statement involved.
Basically, your message boils down to
"It does not work. Please help ', without any relevant information.
I say this because INSERT SELECT is the fastest method available. OK, you can try the hint APPEND, but in this case, you need to rebuild all indexes. Something that you say that you can't do.
BULK inserts will be slower, SQL * Loader will be slower too, since it's SQLnet. INSERT SELECT is a side operation server.
And the 'solution' to do through a file... UM, let's not talk. It simply doesn't get it.-----
Sybrand Bakker
Senior Oracle DBA -
XML data in the table using sql/plsql
Hi experts,
Could you please help with the following requirement. I have the tags xml (.xml on a server file) below. I need to access this file and read the XML and insert into the db table using sql and plsql. Is it possible with the cdata below? And there is a nested this table.
Could someone please guide me if you have a sample code file and xml.
<? XML version = "1.0" encoding = "UTF-8"? >
< generation_date > <! [CDATA [17/11/2015]] > < / generation_date >
< generated_by > <! [CDATA [Admin Admin]] > < / generated_by >
< year > <! [CDATA [2015]] > < / year >
< month > <! [CDATA [01]] > < / month >
< author >
< author > <! [CDATA [user author]] > < / author > < author_initial > <! [CDATA [user]] > < / author_firstname > < author_country > <! [CDATA [author]] > < / author_lastname >
< author_email > <! [CDATA [[email protected]]] > < / author_email >
< author_data_01 > <! [CDATA []] > < / author_data_01 >
< author_data_02 > <! [CDATA []] > < / author_data_02 >
< items >
< article_item >
< article_id > <! [CDATA [123456]] > < / article_id >
< publication > <! [CDATA [Al Bayan]] > < / publication >
< section > <! [CDATA [Local]] > < / section >
< issue_date > <! [CDATA [11/11/2015]] > < / issue_date >
< page > <! [CDATA [2]] > < / print this page >
< article_title > <! [CDATA [title.]] > < / article_title > < number_of_words > <! [CDATA [165]] > < / number_of_words >
< original_price > <! [CDATA [200]] > < / original_price >
< original_price_currency > <! [CDATA [DEA]] > < / original_price_currency >
< price > <! [CDATA [250]] > < / price >
< price_currency > <! [CDATA [DEA]] > < / price_currency >
< / article_item >
< / articles >
< total_amount > <! [CDATA [250]] > < / total_amount >
< total_amount_currency > <! [CDATA [DEA]] > < / total_amount_currency >
< / author >
< / xml >
Thanks in advance,
Suman
XMLTABLE using...
SQL > ed
A written file afiedt.buf1 with t (xml) as (select xmltype ('))
2 ") of the double)"
3
4
5
6
7
8
9
10
11
[[12[email protected]]] >
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34-
35 end of sample data
36-
37 - assumptions:
(38 - a) XML may have several tags
(39 - b) eachmay contain more
40-
41 select x.gen_by, x.gen_date, x.mn, x.yr
42, y.author, y.auth_fn, y.auth_ln, y.auth_cnt, y.auth_em, y.auth_d1, y.auth_d2
43, z.id, z.pub, z.sec, z.iss_dt, z.pg, z.art_ttl, z.num_wrds, z.oprice, z.ocurr, z.price, z.curr
44 t
45, xmltable ('/ authxml')
from $ 46 t.xml
path of 47 columns gen_date varchar2 (10) '. / generation_date'
48, path of varchar2 (15) of gen_by '. / generated_by'
49, path of varchar2 (4) year '. "/ year"
50 varchar2 (2) mn road '. "/ month"
51, path of xmltype authors '.'
52 ) x
53, xmltable ('/ authxml/authors ')
from $ 54 x.authors
author of 55 path of varchar2 columns (15) '. / author'
56, path of varchar2 (10) of auth_fn '. / author_firstname'
57, path of varchar2 (10) of auth_ln '. / author_lastname'
58 road of VARCHAR2 (3) auth_cnt '. / author_country'
59 road of varchar2 (20) of auth_em '. / author_email'
60 road of varchar2 (5) of auth_d1 '. / author_data_01'
61, path of varchar2 (5) of auth_d2 '. / author_data_02'
62, path of xmltype articles '. / Articles'
63 ) y
64, xmltable ('/ Articles/article_item ')
from $ 65 y.articles
path id 66 number columns '. / article_id'
67, path of varchar2 (10) pub '. ' / publication.
68 road of varchar2 (10) dry '. / section'
69, path of varchar2 (10) of iss_dt '. / issue_date'
70 road of VARCHAR2 (3) pg '. "/ print this page"
71, path of varchar2 (20) of art_ttl '. / article_title'
72, path of varchar2 (5) of num_wrds '. / number_of_words'
73, path of varchar2 (5) of oprice '. / original_price'
74 road to VARCHAR2 (3) ocurr '. / original_price_currency'
75, path of varchar2 (5) price '. "/ price"
76, path of VARCHAR2 (3) curr '. / price_currency'
77* ) z
SQL > /.GEN_DATE GEN_BY YEAR MN AUTHOR AUTH_FN AUTH_LN AUT AUTH_EM AUTH_ AUTH_ ID PUB DRY ISS_DT PG ART_TTL NUM_W OPRIC HEARTS PRICE OCU
---------- --------------- ---- -- --------------- ---------- ---------- --- -------------------- ----- ----- ---------- ---------- ---------- ---------- --- -------------------- ----- ----- --- ----- ---
17/11/2015 Admin Admin 2015 01 user author user author [email protected] 123456 UAE Al Bayan Local 11/11/2015 2 is the title. 165 200 AED AED 250Of course, you'll want to change the types of data, etc. as needed.
I assumed that the XML can contain several "
" sections and that each section can contain several entries. Thus the XMLTABLE aliasing as 'x' gives information of XML, and supplies the data associated with the XMLTABLE with alias 'y' which gets the multiple authors, which itself
section of the XMLTABLE with alias 'z' for each of the article_item. CDATA stuff are handled automatically by SQLX (XML functionality integrated into Oracle's SQL)
-
"missing the SELECT keyword" error during an insert into the temporary table using the blob value
I'm trying to insert into an oracle temp table using select that retrieves data from a blob field but I get the error: "lack the SELECT keyword.
How we store temporary in oracle result when we make this type of operation (extraction of data in fields and try to load them into a separate table on the fly.?)
with cte as)
Select user_id, utl_raw.cast_to_varchar2 (dbms_lob.substr (PREFERENCES)) as USER my_blob
)
create table new_table as
SELECT user_id,EXTRACTvalue(xmltype(e.my_blob),'/preferences/locale') regional settings
E ETC
----------------------------------------------------------------------------------
BLOB data - value - which is
<? XML version = "1.0" encoding = "ISO-8859-1" ?>
- < Preferences >< time zone > America/New_York < / > zone< displayscheduleinusertimezone > Y < / displayscheduleinusertimezone >< local > Spanish < /locale >< DateFormat > JJ/mm/aaaa < / DateFormat >< timeFormat > hh: mm aaa < / timeFormat >< longformat > Long_01 < / longformat >< doubleformat > Double_01 < / doubleformat >< percentformat > Percentage_01 < / percentformat >< currencyformat > Currency_01 < / currencyformat >< / Preferences >
A WITH clause that must immediately precede the SELECT keyword:
SQL > create table t:
2 with the o as (select double dummy)
3 select * West longitude;
Table created.
-
Hello
I have a procedure that takes xmltype as input parameter that contains data such as:
<? XML version = "1.0"? >
rowset <>
< ROW >
< > 7782 EMPNO < / EMPNO >
CLARK < ENAME > < / ENAME >
MANAGER < JOB > < / JOB >
< MGR > 7839 < / MGR >
< HIREDATE > 9 June 81 < / HIREDATE >
< SAL > 2450 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< ROW >
< > 7839 EMPNO < / EMPNO >
KING of < ENAME > < / ENAME >
PRESIDENT < JOB > < / JOB >
< HIREDATE > 17 November 81 < / HIREDATE >
< SAL > 5000 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< ROW >
< > 7934 EMPNO < / EMPNO >
MILLER < ENAME > < / ENAME >
CLERK of < JOB > < / JOB >
< MGR > 7782 < / MGR >
< HIREDATE > 23 January 82 < / HIREDATE >
< SAL > 1300 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< / LINES >
I analyze this data and insert into the employee table.
I remember that using the extract function we can do, but I do not get it exactly.
Can you please help me in this.
Thank you
VinodSee [url http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions251.htm#CIHGGHFB] XMLTABLE
For example:
-- INSERT INTO
WITH x AS (SELECT XMLTYPE(' 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7839 KING PRESIDENT 17-NOV-81 5000 10 7934 MILLER CLERK 7782 23-JAN-82 1300 10 -
Help to download the xml of the oracle table below
Dear all,
I tried best to download the below xml to oracle table but giving the link between the tables is very difficult for me. can someone help me to import the XML below for oracle table
<? XML version = "1.0" encoding = "utf-8"? >
< Claim.Submission xmlns:tns = "http://www.haad.ae/DataDictionary/CommonTypes" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: noNamespaceSchemaLocation = "http://www.haad.ae/DataDictionary/CommonTypes/ClaimSubmission.xsd" >
< header >
MF65 < SenderID > < / SenderID >
C014 < ReceiverID > < / ReceiverID >
< TransactionDate > 03/12/2012 10:40 < / TransactionDate >
< RecordCount > 1 < / RecordCount >
< DispositionFlag > PRODUCTION < / DispositionFlag >
< / header >
< claim >
< ID > 23112 / < ID >
< MemberID > 100000874 < / MemberID >
A022 < PayerID > < / PayerID >
MF65 < ProviderID > < / ProviderID >
< EmiratesIDNumber > 111-1111-1111111-1 < / EmiratesIDNumber >
< raw > 115 < / gross >
< PatientShare > 20 < / PatientShare >
< net > 95 < / Net >
< meeting >
MF65 < FacilityID > < / FacilityID >
< type > 1 < / Type >
< > 47685 PatientID < / PatientID >
< Start > 02/11/2012 12:00 < / Start >
< / meeting >
< Diagnostics >
Principal of < type > < / Type >
< code > < code > 461.9
< / Diagnosis >
< Diagnostics >
Secondary < type > < / Type >
< code > < code > 462
< / Diagnosis >
< activity >
23112_1 < ID > < /ID >
< Start > 02/11/2012 12:00 < / Start >
< type > 3 < / Type >
< code > < code > 99202
< quantity > 1 < / quantity >
< net > 95 < / Net >
D1310 < clinician > < / clinician >
< / activity >
< / claim >
< Claim.Submission >Pls tell me how I can get
Have you considered using the storage relational object for this?
Since you have patterns, you could record in the database, which will automatically create storage appropriate for your XML documents as well as validate at the time of insertion.
You can then create individual views to query the nested parts of the document and finally insert the data into relational tables final.See the documentation for an introduction to the concepts:
http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/partpg2.htm#g997354You will find examples on the {forum: id = 34} forum and its FAQ: {: identifier of the thread = 410714}
-
How to insert rows from an xml file in a table
IM Using Oracle 11g, is show below error when I run...
declare
charString varchar2 (80);
finalStr varchar2 (400): = null;
whole rowsp;
v_FileHandle UTL_FILE. TYPE_DE_FICHIER;
Start
-the name of the table specified in our DTD
xmlgen.setRowsetTag ('Zipcodes');
-the name of the data set as shown in our DTD
xmlgen.setRowTag ('mappings');
-to get the result on the screen
dbms_output. Enable (100000);
-Open the XML document in read-only mode
v_FileHandle: = utl_file.fopen (TMP_DIR1,'XML_NEW_CITIES.) XML', 'r');
loop
BEGIN
UTL_FILE.get_line (v_FileHandle, charString);
exception
When no_data_found then
UTL_FILE.fclose (v_FileHandle);
"exit";
END;
dbms_output.put_line (charstring);
If finalStr is not null then
finalStr: = finalStr | charString;
on the other
finalStr: = charString.
end if;
end loop;
-for the insertion of XML data in the table
rowsp: = xmlgen.insertXML('SYS.) Codes POSTAL, finalStr);
dbms_output.put_line ('INSERT FACT' |) To_char (rowsp));
xmlgen.resetOptions;
end;
/
XML_NEW_CITIES. XML is
<? XML version = "1.0"? >
< zip codes >
< Record mappings = "4" >
CA < STATE_ABBREVIATION > < / STATE_ABBREVIATION >
< ZIPCODE > 94301 < / code >
< CITY > Palo Alto < / CITY >
< / maps >
< Record mappings = "5" >
< STATE_ABBREVIATION > CO < / STATE_ABBREVIATION >
< ZIPCODE > 80323 < / code >
< ZIP_CODE_EXTN > 9277 < / ZIP_CODE_EXTN >
Boulder < CITY > < / CITY >
< / maps >
< / zip codes >
Error report:
ORA-06550: line 8, column 3:
PLS-00201: identifier ' XMLGEN. SETROWSETTAG' must be declared
ORA-06550: line 8, column 3:
PL/SQL: Statement ignored
ORA-06550: line 10, column 3:
PLS-00201: identifier ' XMLGEN. SETROWTAG' must be declared
ORA-06550: line 10, column 3:
PL/SQL: Statement ignored
ORA-06550: line 14, column 34:
PLS-00201: identifier 'TMP_DIR1' must be declared.
ORA-06550: line 14, column 3:
PL/SQL: Statement ignored
ORA-06550: line 31, column 12:
PLS-00201: identifier ' XMLGEN. INSERTXML' must be declared
ORA-06550: line 31, column 3:
PL/SQL: Statement ignored
ORA-06550: line 33, column 3:
PLS-00201: identifier ' XMLGEN. RESETOPTIONS' must be reported
ORA-06550: line 33, column 3:
PL/SQL: Statement ignored
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error
Published by: 898235 on November 20, 2011 23:02OK, so you tried the XMLTable example, or wait for someone write at the bottom for you? :)
You must first create an object of directory Oracle pointing to the physical location of the file (must be somewhere on the db server or at a location that the db server can access on the network).
Then, create the procedure, in this case a simple INSERT SELECT:SQL> create directory tmp_dir as 'c:\temp'; Directory created SQL> create table zipcodes ( 2 state_abbreviation varchar2(2), 3 zipcode varchar2(5), 4 zip_code_extn varchar2(10), 5 city varchar2(80) 6 ); Table created SQL> CREATE OR REPLACE PROCEDURE insertZipcodes ( 2 p_directory IN VARCHAR2 3 , p_filename IN VARCHAR2 4 ) 5 IS 6 BEGIN 7 8 INSERT INTO zipcodes (state_abbreviation, zipcode, zip_code_extn, city) 9 SELECT state_abbreviation 10 , zipcode 11 , zip_code_extn 12 , city 13 FROM XMLTable('/Zipcodes/mappings' 14 passing xmltype(bfilename(p_directory, p_filename), nls_charset_id('AL32UTF8')) 15 columns state_abbreviation varchar2(2) path 'STATE_ABBREVIATION' 16 , zipcode varchar2(5) path 'ZIPCODE' 17 , zip_code_extn varchar2(10) path 'ZIP_CODE_EXTN' 18 , city varchar2(80) path 'CITY' 19 ) 20 ; 21 22 END; 23 / Procedure created SQL> exec insertZipcodes('TMP_DIR', 'xml_new_cities.xml'); PL/SQL procedure successfully completed SQL> commit; Commit complete SQL> select * from zipcodes; STATE_ABBREVIATION ZIPCODE ZIP_CODE_EXTN CITY ------------------ ------- ------------- --------------- CA 94301 Palo Alto CO 80323 9277 Boulder
-
Merge the XML document in a table
Hello
I want to merge some of the values of an xml document in a table "Project_Table".
CREATE TABLE Project_Table
(
TASK_ID NUMBER (15),
TASK_NAME VARCHAR2 (100 BYTE),
START_DATE DATE,
)
I am using the following procedure, that I adapted from another post. It inserts null values, I think because I'm not showing the nodes correctly.
DECLARE
BFILE v_bfile: = BFILENAME ("'DTEMP","test.xml");
v_clob CLOB.
BEGIN
-Create directory DTEMP as "C:\TEMP";
-grant read the < schema > DTEMP directory;
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);
Dbms_output.put_line (v_clob);
MERGE IN project_table t
USING (SELECT TO_NUMBER (EXTRACTVALUE (VALUE (x), ' / task ')) task_id,)
To_date (EXTRACTVALUE (value (x), "/ start"), 'DD-MM-YYYY') start_date,
EXTRACTVALUE (value (x), "/ name") TaskName
(SELECT XMLTYPE (v_clob) XML
THE DOUBLE).
TABLE (XMLSEQUENCE (EXTRACT (xml, ' / project'))) x) r
WE (t.task_id = r.task_id)
WHEN MATCHED THEN
UPDATE
SET t.start_date = r.start_date, t.task_name = r.task_name
WHEN NOT MATCHED THEN
INSERT (task_id, start_date, taskname)
VALUES (r.task_id, r.start_date, r.task_name);
COMMIT;
END;
This is the document of test.xml.
<? XML version = "1.0" encoding = "UTF-8"? >
-name of the project 'ProjectName' company 'Company' webLink = = = "" view-date = '2009-12-14"see-index '0' = gantt-Divider-location = '300' resource-divider-card ="300"version ="2.0">"
< description / >
< zoom-view state = "default: 8" / >
-<!
->
-< calendars >
-day-types >
< day-type id = '0' / >
< day-type id = "1" / >
-< Calendar id = "1" name = "default" >
< Sun weeks default = '0' LUN '0' = TEU = '0' kills = '0' game = '0' Fri '0' = Saturday = '0' / >
< overloaded-day-types / >
< days / >
< / calendar >
< / day-types >
< / calendars >
-task color = "#8cb6ce" >
-< taskproperties >
< taskproperty id = "tpd0" name = 'type' type = 'default' valuetype = "icon" / >
< taskproperty id = "TDP1" name = 'priority' type = 'default' valuetype = "icon" / >
< taskproperty id = "tpd2" name = 'info' type = 'default' valuetype = "icon" / >
< taskproperty id = "tpd3" name = "name" type = 'default' valuetype = "text" / >
< taskproperty id = "tpd4" name = "begindate" type = 'default' valuetype = "date" / >
< taskproperty id = "tpd5" name = "enddate" type = 'default' valuetype = "date" / >
< taskproperty id = "tpd6" name = "Duration" type = 'default' valuetype = "int" / >
< taskproperty id = "tpd7" name = "completion" type = 'default' valuetype = "int" / >
< taskproperty id = "tpd8" name = "Coordinator" type = 'default' valuetype = "text" / >
< taskproperty id = "tpd9" name = "predecessorsr" type = "default" valuetype = "text" / >
< / taskproperties >
< job id = '0' name = 'TaskA"color =" #0099cc "form = meeting"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"="false"start ="2010-01-28"duration ="1"complete ="0"priority ="1"expand ="true"/ >
< task id = "1" name = "TaskB" color = "#ff0000" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-01-28" duration = "1" complete = "100" priority = "1" expand = "true" / >
< job id = "2" name = 'Day' color = "#ff9933" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "19" complete = "0" priority = "1" expand = "true" / >
< job id = "3" name = "TaskD" color = "#ff0000" form = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" meeting = "false" start = "2010-02-01" duration = "32" full = "100" priority = "1" expand = "true" / >
< job id = "4" name = "TaskE" color = "#66ff99" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "67" complete = "0" priority = "1" expand = "true" / >
< job id = "5" name = "TaskF" color = "#66ff99" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "46" complete = "10" priority = "1" expand = "true" / >
< job id = "6" name = "TaskG" color = "#00cccc" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-03-15" duration = "30" complete = "0" priority = "1" expand = "true" / >
< job id = "7" name = "TaskH" color = "#00cccc" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-03-15" duration = "103" full '1' = '1' priority = expand = "true" / >
< job id = "8" name = "TaskI" color = "#0000ff" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = '2010-04-26' length = "11" complete = "0" priority = "1" expand = "true" / >
< job id = '9' name = 'TaskJ"color =" #0000ff "form = meeting"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"="false"start = '2010-04-26' length ="11"complete ="0"priority ="1"expand ="true"/ >
< job id = "10" name = "TaskK" color = "#000000" meeting = 'false' start time = "2010-07-12" = "65" full = "0" priority = "1" expand = "true" / >
< / tasks >
< resources / >
< allowances / >
< holiday / >
-< taskdisplaycolumns >
< displaycolumn property id = "tpd3" order = "0" width = "75" / >
< displaycolumn property id = "tpd4" order = "1" width = "75" / >
< displaycolumn property id = "tpd5" order = "2" width = "75" / >
< displaycolumn property id = "tpd7" order = "3" width = "75" / >
< / taskdisplaycolumns >
< Previous / >
< roles roles-name = "Default" / >
< / project >
Any ideas how to change the procedure, in order to merge the data in the xml document in the table?
Thank youHello
Here's what you need in your USING clause:
SELECT to_number(extractvalue(column_value, 'task/@id')) as task_id, to_date(extractvalue(column_value, 'task/@start'), 'YYYY-MM-DD') as start_date, extractvalue(column_value, 'task/@name') as task_name FROM TABLE( XMLSEQUENCE( EXTRACT(xmltype(v_clob), '//task') ) )
Since you want nodes "task" request, just extract them directly. In addition, 'id', 'start', 'name' is attributes, you must access them with an '@'.
You can also take a look at function XMLTABLE (which tends to replace construction TABLE (XMLSEQUENCE (...))):
SELECT * FROM XMLTABLE( '//task' passing xmltype(v_clob) columns task_id number(15) path '/task/@id', start_date date path '/task/@start', task_name varchar2(100) path '/task/@name' )
Edit: the XMLType constructor overload taking a BFILE type as an argument, so you can simplify the code a bit more:
DECLARE v_xml XMLTYPE := XMLTYPE( BFILENAME('DTEMP', 'test.xml'), nls_charset_id('AL32UTF8') ); BEGIN MERGE INTO project_table t USING ( SELECT * FROM XMLTABLE( '//task' passing v_xml columns task_id number(15) path '/task/@id', start_date date path '/task/@start', task_name varchar2(100) path '/task/@name' ) ) r ON (t.task_id = r.task_id) WHEN MATCHED THEN ... WHEN NOT MATCHED THEN ... ; ... END;
HTH
Published by: odie_63 on March 18, 2010 12:13
Published by: odie_63 on March 18, 2010 12:15
-
How can I use the configuration xml into native c + c++ file / qml
I want to use a config file xml in my app.but I don't know what path should I place my xml file, and how to read it.how to get the path...
of course, you can put the XML into your project. But why would you do that?
-
Look for patterns in a string and insert it into a new table
I need to write a query that finds a number of location of employees that has been changed from old to new
EMPLOYEE_DESC
Description of the ID
1 employee location was change from 877-287-8765 to 876-876-0976
2 location of employee was passing of 877-287-8766 at 876-879-0976
slot 3 is passed under NONE FOUND TO577-75-5951
Once I get the identifier for the old and the new, I need to insert into the new table
INSERT INTO TABLE_B
(OLD_LOC_ID, NEW_LOC_ID)
VALUES (OLD_LOC_ID, NEW_LOC_ID);
TABLE_B
ID OLD_LOC_ID NEW_LOC_ID
1 287-877-8765 876-876-0976
2 287-877-8766 879-876-0976
3. NONE FOUND 577-75-5951
The problem is that there is no fixed model for these records. I guess I have to insert the records that correspond to a fixed patten and snoop then through other manually. Is there a REGULAR expression feature that can help me grep values old and new location for the employee_desc number?
Thank you
Kevin
Hello
Kevin_K wrote:
... The problem is that there is no fixed model for these records. I guess I have to insert the records that correspond to a fixed patten and snoop then through other manually. Is there a REGULAR expression feature that can help me grep values old and new location for the employee_desc number?
Thank you
Kevin
Yes, you can do something like this:
REGEXP_SUBSTR (description
, ' ((NONE FOUND) |) (\d+-\d+-\d+)) * To * \d+-\d+-\d+'
1
1
'i' - case-insensitive
)
It looks like for
- a "phone number" or the words "NOTHING FOUND", followed immediately by
- 0 or more spaces followed immediately by
- the word "TO", followed immediately
- 0 or more spaces followed immediately by
- a "phone number".
where a "phone number" is defined as
- 1 or more digits, followed immediately
- a hyphen, immediately followed by
- 1 or more digits, followed immediately
- a hyphen, immediately followed by
- 1 or more digits
- You can also get the parts before and after 'TO' separately.
-
Inserting into a temporary table
Hi all
I use this code to insert into a temporary table
INSERT INTO VISIT_TEST
(NO, VISIT_ID)
VALUES
(1,: ALL_ADMITTED_PATIENT.) VISIT_ID); -guess: ALL_ADMITTED_PATIENT. VISIT_ID is another number.
COMMIT;
It inserts nothing,
but when I try to insert all the values of pl/sql with the same way
INSERT INTO VISIT_TEST (NO., VISIT_ID) VALUES (2, 4);
It inserts with success.
the code for creating the table of tempo is
CREATE A VISIT_TEST GLOBAL TEMPORARY TABLE (NO NUMBER, NUMBER VISIT_ID) COMMIT PRESERVE ROWS
Why does not insert on it data?
PS: the whole issue is that I run a report from a form, and the query of the report is based on the temporary table.
what I want to know is, when I run the report from inside my form, is considered a new session, and this is why the report cannot see the data in the table of tempo or am I wrong?
Thank you
> when I run the report of my form, which constitutes a new session, and this is why the report cannot see the data in the table of tempo, or am I wrong?
You're not bad. Forms and reports use separate database sessions. Reports can not see TWG data entered via Forms module.
Concerning
-
How to convert XML into a PDF file?
I use Adobe Acrobat X Pro 10.0. I saved a PDF file in an XML 1.0 document. I would like to be able to send this XML document and have the recipient opened the XML into a PDF file. Does anyone know how to do this?
Thank you
Hello hilaryb49990629,
Thanks much for posting on the Adobe forums.
I'm sorry, but XML is not a type of file Adobe Acrobat/Reader can open. It can be opened in a browser or Editor (such as Notepad) to view its content.
Kind regards
Ana Maria
Maybe you are looking for
-
Error Microsoft Visual C++ Runtime Library to 44% install world of Warcraft WotLK
Microsoft Visual C++ Runtime Library is the error that I get every once of 44% to install my game World of Warcraft, it happenes with nothing else I even reformatted my system and tried to install it same thing its been happening for weeks now, I nee
-
On a computer running Windows XP Professional SP3, I redirected the "\Windows\Installer" system folder, with a junction to a record point in a tree of directories to a different drive. The operation was conducted and verified using "junction v1.06 -
-
Messages that continue to come whenever I click on anything whatsoever
Whenver, I click on anything on my computer, I receive one of several messages. Back, forward, except as background, select all, create a shortcut, add to Favorites, encoding, properties. Another message I get is to restore, move, size, minimize, m
-
message at startup... Could not load or run 'Rmfile.exe' specified in the registry. Make sure that the file exists on your computer or remove the reference to it in the registry. What do you mean how?
-
Directory of image files and css on mac
in dreamweaver for Mac OS X does not work"< link href="/css/default.css "rel ="stylesheet"/ >in dreamweaver for Mac OS X works only:< link href = "file:///Macintosh HD/Users/DJMatrix/Downloads/MySite/css/default.css" rel = "stylesheet" / >works in dr