Skip to Main Content

DevOps, CI/CD and Automation

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Loading XML Data into Relational Table

phannah1Mar 5 2015 — edited Mar 6 2015

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!

This post has been answered by odie_63 on Mar 6 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2015
Added on Mar 5 2015
2 comments
1,195 views