{"id":1106,"date":"2019-08-19T15:09:46","date_gmt":"2019-08-19T13:09:46","guid":{"rendered":"https:\/\/mjr.gmbh\/post\/creating-xml-files-via-sql\/"},"modified":"2023-03-15T09:39:33","modified_gmt":"2023-03-15T08:39:33","slug":"creating-xml-files-via-sql","status":"publish","type":"post","link":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/","title":{"rendered":"Creating XML-Files via SQL"},"content":{"rendered":"<p><a ref=\"magnificPopup\" href=\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-397 size-full\" src=\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\" alt=\"xmlwithsql Thumbnail\" width=\"700\" height=\"467\" srcset=\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png 700w, https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql-300x200.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n<p>We will show you how to easily convert content of your database tables into an XML file.<\/p>\n<p>And all it takes is just a SQL statement and a CL command. We start off by preparing a sample table, this one will have three columns and three rows for testing:<\/p>\n<div>\n<pre>CREATE TABLE qtemp.TESTXML (FIELD1 CHAR (10 ) , FIELD2 CHAR (256 ), FIELD3 NUMERIC (10 , 3));\r\nINSERT INTO qtemp.TESTXML VALUES('Record1', 'Description1', 1);\r\nINSERT INTO qtemp.TESTXML VALUES('Record2', 'Description2', 2);\r\nINSERT INTO qtemp.TESTXML VALUES('Record3', 'Description3', 3);<\/pre>\n<p>After executing the commands from above, our sample table has been created.<\/p>\n<table border=\"3\">\n<tbody>\n<tr>\n<td>Record1<\/td>\n<td>Description1<\/td>\n<td>1.000<\/td>\n<\/tr>\n<tr>\n<td>Record2<\/td>\n<td>Description2<\/td>\n<td>2.000<\/td>\n<\/tr>\n<tr>\n<td>Record3<\/td>\n<td>Description3<\/td>\n<td>3.000<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Additionally, we need a temporary table to store our XML data:<\/p>\n<pre>create table qtemp.myxml as (select xmlserialize( \r\n                                    xmlelement(NAME \"MyXMLRecord\", xmlelement(NAME \"RecNbr\", field3), \r\n                                    xmlelement(NAME \"RecordName\", trim(field1)),\r\n                                    xmlelement(NAME \"RecordDescription\", trim(field2))) \r\n                              as char(1024)) as \"XMLResult\" from qtemp.testxml) with data;\r\n\r\n<\/pre>\n<p>As soon as this is done, our data has been stored within the table and we just have to export them into a text file in the IFS. You can do this by using the following CL command:<\/p>\n<pre>CPYTOIMPF FROMFILE(MYXML) TOSTMF('\/myxml.xml') MBROPT(*REPLACE) FROMCCSID(1252) RCDDLM(*CRLF) STRDLM(*NONE)<\/pre>\n<p>The final result will look like this:<\/p>\n<pre>&lt;MyXMLRecord&gt;&lt;RecNbr&gt;1.000&lt;\/RecNbr&gt;&lt;RecordName&gt;Record1&lt;\/RecordName&gt;&lt;RecordDescription&gt;Description1&lt;\/RecordDescription&gt;&lt;\/MyXMLRecord&gt; \r\n&lt;MyXMLRecord&gt;&lt;RecNbr&gt;2.000&lt;\/RecNbr&gt;&lt;RecordName&gt;Record2&lt;\/RecordName&gt;&lt;RecordDescription&gt;Description2&lt;\/RecordDescription&gt;&lt;\/MyXMLRecord&gt; \r\n&lt;MyXMLRecord&gt;&lt;RecNbr&gt;3.000&lt;\/RecNbr&gt;&lt;RecordName&gt;Record3&lt;\/RecordName&gt;&lt;RecordDescription&gt;Description3&lt;\/RecordDescription&gt;&lt;\/MyXMLRecord&gt;<\/pre>\n<p>Other structures within the XML can easily be created by using the respective keywords.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>We will show you how to easily convert content of your database tables into an XML file. And all it takes is just a SQL statement and a CL command. We start off by preparing a sample table, this one will have three columns and three rows for testing: CREATE TABLE qtemp.TESTXML (FIELD1 CHAR (10&#8230;<\/p>\n","protected":false},"author":18,"featured_media":397,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[18],"tags":[],"tutorial_kategorie":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating XML-Files via SQL - MJR GmbH<\/title>\n<meta name=\"description\" content=\"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating XML-Files via SQL - MJR GmbH\" \/>\n<meta property=\"og:description\" content=\"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"MJR GmbH\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/mjr.gmbh\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-19T13:09:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-15T08:39:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"467\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Julia Eberle\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschrieben von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Julia Eberle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\"},\"author\":{\"name\":\"Julia Eberle\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/#\/schema\/person\/b8d98eff8be96441005da729962f644d\"},\"headline\":\"Creating XML-Files via SQL\",\"datePublished\":\"2019-08-19T13:09:46+00:00\",\"dateModified\":\"2023-03-15T08:39:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\"},\"wordCount\":142,\"publisher\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/#organization\"},\"image\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\",\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"de\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\",\"url\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\",\"name\":\"Creating XML-Files via SQL - MJR GmbH\",\"isPartOf\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\",\"datePublished\":\"2019-08-19T13:09:46+00:00\",\"dateModified\":\"2023-03-15T08:39:33+00:00\",\"description\":\"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.\",\"breadcrumb\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage\",\"url\":\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\",\"contentUrl\":\"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png\",\"width\":700,\"height\":467,\"caption\":\"xmlwithsql Thumbnail\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\/\/testsite.mjr.gmbh\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating XML-Files via SQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/#website\",\"url\":\"https:\/\/testsite.mjr.gmbh\/\",\"name\":\"MJR GmbH\",\"description\":\"MJR GmbH - Digitalisierung f\u00fcr den Mittelstand\",\"publisher\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/testsite.mjr.gmbh\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/#organization\",\"name\":\"MJR GmbH\",\"url\":\"https:\/\/testsite.mjr.gmbh\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/#\/schema\/logo\/image\/\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"MJR GmbH\"},\"image\":{\"@id\":\"https:\/\/testsite.mjr.gmbh\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/mjr.gmbh\",\"https:\/\/www.instagram.com\/mjrgmbh\",\"https:\/\/www.linkedin.com\/company\/mjrgmbh\/\",\"https:\/\/www.youtube.com\/channel\/UCodd4EtgS-12wppUPRXK8QA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/testsite.mjr.gmbh\/#\/schema\/person\/b8d98eff8be96441005da729962f644d\",\"name\":\"Julia Eberle\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/julia-eberle-40751121b\/\"],\"url\":\"https:\/\/testsite.mjr.gmbh\/en\/author\/jeberle\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating XML-Files via SQL - MJR GmbH","description":"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Creating XML-Files via SQL - MJR GmbH","og_description":"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.","og_url":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/","og_site_name":"MJR GmbH","article_publisher":"https:\/\/www.facebook.com\/mjr.gmbh","article_published_time":"2019-08-19T13:09:46+00:00","article_modified_time":"2023-03-15T08:39:33+00:00","og_image":[{"width":700,"height":467,"url":"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png","type":"image\/png"}],"author":"Julia Eberle","twitter_card":"summary_large_image","twitter_misc":{"Geschrieben von":"Julia Eberle","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#article","isPartOf":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/"},"author":{"name":"Julia Eberle","@id":"https:\/\/testsite.mjr.gmbh\/#\/schema\/person\/b8d98eff8be96441005da729962f644d"},"headline":"Creating XML-Files via SQL","datePublished":"2019-08-19T13:09:46+00:00","dateModified":"2023-03-15T08:39:33+00:00","mainEntityOfPage":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/"},"wordCount":142,"publisher":{"@id":"https:\/\/testsite.mjr.gmbh\/#organization"},"image":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png","articleSection":["Tutorials"],"inLanguage":"de"},{"@type":"WebPage","@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/","url":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/","name":"Creating XML-Files via SQL - MJR GmbH","isPartOf":{"@id":"https:\/\/testsite.mjr.gmbh\/#website"},"primaryImageOfPage":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage"},"image":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png","datePublished":"2019-08-19T13:09:46+00:00","dateModified":"2023-03-15T08:39:33+00:00","description":"We will show you how to easily convert content of your database tables into an XML file. It takes just a SQL statement and a CL command.","breadcrumb":{"@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#primaryimage","url":"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png","contentUrl":"https:\/\/testsite.mjr.gmbh\/wp-content\/uploads\/2016\/04\/xmlwithsql.png","width":700,"height":467,"caption":"xmlwithsql Thumbnail"},{"@type":"BreadcrumbList","@id":"https:\/\/testsite.mjr.gmbh\/en\/post\/tutorials-en\/creating-xml-files-via-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/testsite.mjr.gmbh\/en\/"},{"@type":"ListItem","position":2,"name":"Creating XML-Files via SQL"}]},{"@type":"WebSite","@id":"https:\/\/testsite.mjr.gmbh\/#website","url":"https:\/\/testsite.mjr.gmbh\/","name":"MJR GmbH","description":"MJR GmbH - Digitalisierung f\u00fcr den Mittelstand","publisher":{"@id":"https:\/\/testsite.mjr.gmbh\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/testsite.mjr.gmbh\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/testsite.mjr.gmbh\/#organization","name":"MJR GmbH","url":"https:\/\/testsite.mjr.gmbh\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/testsite.mjr.gmbh\/#\/schema\/logo\/image\/","url":"","contentUrl":"","caption":"MJR GmbH"},"image":{"@id":"https:\/\/testsite.mjr.gmbh\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/mjr.gmbh","https:\/\/www.instagram.com\/mjrgmbh","https:\/\/www.linkedin.com\/company\/mjrgmbh\/","https:\/\/www.youtube.com\/channel\/UCodd4EtgS-12wppUPRXK8QA"]},{"@type":"Person","@id":"https:\/\/testsite.mjr.gmbh\/#\/schema\/person\/b8d98eff8be96441005da729962f644d","name":"Julia Eberle","sameAs":["https:\/\/www.linkedin.com\/in\/julia-eberle-40751121b\/"],"url":"https:\/\/testsite.mjr.gmbh\/en\/author\/jeberle\/"}]}},"views":2844,"_links":{"self":[{"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":0,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/media\/397"}],"wp:attachment":[{"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/tags?post=1106"},{"taxonomy":"tutorial_kategorie","embeddable":true,"href":"https:\/\/testsite.mjr.gmbh\/en\/wp-json\/wp\/v2\/tutorial_kategorie?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}