Assumed your XML looks like this:
<root>
<row>
<COL1>123 </COL1>
<COL2>yyyyy</COL2>
<COL3>ABC</COL3>
....
<COL4>ZZZZ</COL4>
</row>
</root>
The SQL Statement for generating a table looks like this:
Create Table YourSchema/YourTable as
(Select *
from XMLTABLE('root/row'
passing xmlparse(Document
Get_xml_file('/home/YourDir1/YourDir2/YourXMLTable.xml'))
Columns COL1 Integer Path 'COL1',
COL2 VarChar(50) Path 'COL2',
...
COLN VarChar(50) Pach 'COLN') x )
With Data;
Detailed information about the SQL XML functions can be found here:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzasp/rzasppdf.pdf?
view=kc
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Tim
Fathers
Sent: Donnerstag, 28. Januar 2021 23:51
To: midrange-l@xxxxxxxxxxxxxxxxxx
Subject: Re: How to Convert an XML in IFS directory to a DB2 file
You can do this very easily with SQL, using the GET_XML_FILE(..) function to
read the file into an XML variable and then the XMLTABLE function to parse
it into the database.
Tim.
________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Mohan
Eashver <mohankva@xxxxxxxxx>
Sent: 28 January 2021 20:44
To: midrange-l@xxxxxxxxxxxxxxxxxx <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: How to Convert an XML in IFS directory to a DB2 file
Hi All.
I have several RPG programs that produce XML files in IFS. They are
generated using CGIDEV2.
I could change each of the RPG programs that generate XML, to also write to
a DB2 File.
But I am looking at an easier solution.
Appreciate if you could share with us, any technique you played with, to
convert the XML into a DB2 table.
----
Regards,
Mohan Eashver
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.