doc-exports/docs/dws/dev/dws_06_0354.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

157 lines
14 KiB
HTML

<a name="EN-US_TOPIC_0000001450296656"></a><a name="EN-US_TOPIC_0000001450296656"></a>
<h1 class="topictitle1">Mapping a Table to XML</h1>
<div id="body0000001450296656"><p id="EN-US_TOPIC_0000001450296656__p158853920217">The functions in this section map the contents of the relational table to XML values. This is similar to exporting table in XML format.</p>
<p id="EN-US_TOPIC_0000001450296656__p062315163917">Function parameters:</p>
<ul id="EN-US_TOPIC_0000001450296656__ul1662431617911"><li id="EN-US_TOPIC_0000001450296656__li1262412163916"><strong id="EN-US_TOPIC_0000001450296656__b1941830021112838">tbl</strong>: table name.</li><li id="EN-US_TOPIC_0000001450296656__li156242161915"><strong id="EN-US_TOPIC_0000001450296656__b70262006694435">nulls</strong>: indicates whether the output contains null values. If the value is <strong id="EN-US_TOPIC_0000001450296656__b62755750194435">true</strong>, the null value in the column is <strong id="EN-US_TOPIC_0000001450296656__b206587967894435">&lt;columnname xsi:nil="true"/&gt;</strong>. If the value is <strong id="EN-US_TOPIC_0000001450296656__b20357623494435">false</strong>, the columns containing null values are omitted from the output.</li><li id="EN-US_TOPIC_0000001450296656__li136243161891"><strong id="EN-US_TOPIC_0000001450296656__b157095907694435">tableforest</strong>: If this parameter is set to <strong id="EN-US_TOPIC_0000001450296656__b42090749294435">true</strong>, XML fragments are generated. If this parameter is set to <strong id="EN-US_TOPIC_0000001450296656__b190491872594435">false</strong>, XML files are generated.</li><li id="EN-US_TOPIC_0000001450296656__li462417161093"><strong id="EN-US_TOPIC_0000001450296656__b5211203294435">targetns</strong>: specifies the XML namespace of the desired result. If this parameter is not specified, an empty string is passed.</li><li id="EN-US_TOPIC_0000001450296656__li462419161899"><strong id="EN-US_TOPIC_0000001450296656__b184589291494435">query</strong>: SQL query statement</li><li id="EN-US_TOPIC_0000001450296656__li762415163912"><strong id="EN-US_TOPIC_0000001450296656__b130317327194435">cursor</strong>: cursor name</li><li id="EN-US_TOPIC_0000001450296656__li116246162915"><strong id="EN-US_TOPIC_0000001450296656__b74288492694435">count</strong>: amount of data obtained from the cursor</li><li id="EN-US_TOPIC_0000001450296656__li26241216798"><strong id="EN-US_TOPIC_0000001450296656__b227648976112838">schema</strong>: schema name</li></ul>
<div class="section" id="EN-US_TOPIC_0000001450296656__section2079310394914"><h4 class="sectiontitle">table_to_xml(tbl regclass, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p979313393919">Description: Maps the contents of a table to XML values.</p>
<p id="EN-US_TOPIC_0000001450296656__p1879303916915">Return type: XML</p>
<p id="EN-US_TOPIC_0000001450296656__p1061234217512">If <strong id="EN-US_TOPIC_0000001450296656__b1481727194113">tableforest</strong> is false, the XML document in the result is similar to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001450296656__screen15958105535110"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span></pre></div></td><td class="code"><div><pre><span></span><span class="o">&lt;</span><span class="n">tablename</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="k">row</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="n">columnname1</span><span class="o">&gt;</span><span class="k">data</span><span class="o">&lt;/</span><span class="n">columnname1</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="n">columnname2</span><span class="o">&gt;</span><span class="k">data</span><span class="o">&lt;/</span><span class="n">columnname2</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;/</span><span class="k">row</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="k">row</span><span class="o">&gt;</span>
<span class="w"> </span><span class="p">...</span>
<span class="w"> </span><span class="o">&lt;/</span><span class="k">row</span><span class="o">&gt;</span>
<span class="w"> </span><span class="p">...</span>
<span class="o">&lt;/</span><span class="n">tablename</span><span class="o">&gt;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001450296656__p5613174217512">If <strong id="EN-US_TOPIC_0000001450296656__b17879434204613">tableforest</strong> is true, the XML content in the result is similar to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001450296656__screen193921849115118"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td><td class="code"><div><pre><span></span><span class="o">&lt;</span><span class="n">tablename</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="n">columnname1</span><span class="o">&gt;</span><span class="k">data</span><span class="o">&lt;/</span><span class="n">columnname1</span><span class="o">&gt;</span>
<span class="w"> </span><span class="o">&lt;</span><span class="n">columnname2</span><span class="o">&gt;</span><span class="k">data</span><span class="o">&lt;/</span><span class="n">columnname2</span><span class="o">&gt;</span>
<span class="o">&lt;/</span><span class="n">tablename</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">tablename</span><span class="o">&gt;</span>
<span class="w"> </span><span class="p">...</span>
<span class="o">&lt;/</span><span class="n">tablename</span><span class="o">&gt;</span>
<span class="p">...</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section454710109106"><h4 class="sectiontitle">table_to_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p108718236458">Description: Maps a relational table schema to an XML schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p1419281671019">Return type: XML</p>
<p id="EN-US_TOPIC_0000001450296656__p176578488124">The result of the schema content mapping is similar to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001450296656__screen2658174511132"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span><span class="o">&lt;</span><span class="n">schemaname</span><span class="o">&gt;</span>
<span class="n">table1</span><span class="o">-</span><span class="n">mapping</span>
<span class="n">table2</span><span class="o">-</span><span class="n">mapping</span>
<span class="p">...</span>
<span class="o">&lt;/</span><span class="n">schemaname</span><span class="o">&gt;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001450296656__p36571548181215">The format of the table mapping depends on the <strong id="EN-US_TOPIC_0000001450296656__b8454411144714">tableforest</strong> parameter.</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section32078913119"><h4 class="sectiontitle">table_to_xml_and_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p78713234453">Description: Maps a relational table to XML values and schema documents.</p>
<p id="EN-US_TOPIC_0000001450296656__p138801243101114">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section362311111117"><h4 class="sectiontitle">query_to_xml(query text, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p12871223164512">Description: Maps the contents of an SQL query to XML values.</p>
<p id="EN-US_TOPIC_0000001450296656__p1248314482119">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section5917142113"><h4 class="sectiontitle">query_to_xmlschema(query text, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p198718235458">Description: Maps an SQL query into an XML schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p05325535114">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section44601416111117"><h4 class="sectiontitle">query_to_xml_and_xmlschema(query text, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p387823204512">Description: Maps SQL queries to XML values and schema documents.</p>
<p id="EN-US_TOPIC_0000001450296656__p2099935716112">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section67117618110"><h4 class="sectiontitle">cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p198792314457">Description: Maps a cursor query to an XML value.</p>
<p id="EN-US_TOPIC_0000001450296656__p128872310459">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section1535216313117"><h4 class="sectiontitle">cursor_to_xmlschema(cursor refcursor, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p188820239459">Description: Maps a cursor query to an XML schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p1672610151129">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section10295171181119"><h4 class="sectiontitle">schema_to_xml(schema name, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p16881223184516">Description: Maps a table in a schema to an XML value.</p>
<p id="EN-US_TOPIC_0000001450296656__p97821919101212">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section14941195820105"><h4 class="sectiontitle">schema_to_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p688172364510">Description: Maps a table in a schema to an XML schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p49682421217">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section11701056141016"><h4 class="sectiontitle">schema_to_xml_and_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p19881923174519">Description: Maps a table in a schema to an XML value and a schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p24361309126">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section642914534107"><h4 class="sectiontitle">database_to_xml(nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p16881623164510">Description: Maps a database table to an XML value.</p>
<p id="EN-US_TOPIC_0000001450296656__p78862394512">Return type: XML</p>
<p id="EN-US_TOPIC_0000001450296656__p855722101311">The result of the database content mapping may be similar to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001450296656__screen114622010151318"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span></pre></div></td><td class="code"><div><pre><span></span><span class="o">&lt;</span><span class="n">dbname</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">schema1name</span><span class="o">&gt;</span>
<span class="w"> </span><span class="p">...</span>
<span class="o">&lt;/</span><span class="n">schema1name</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">schema2name</span><span class="o">&gt;</span>
<span class="w"> </span><span class="p">...</span>
<span class="o">&lt;/</span><span class="n">schema2name</span><span class="o">&gt;</span>
<span class="p">...</span>
<span class="o">&lt;/</span><span class="n">dbname</span><span class="o">&gt;</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section10893205011017"><h4 class="sectiontitle">database_to_xmlschema(nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p3881923124516">Description: Maps a database table to an XML schema document.</p>
<p id="EN-US_TOPIC_0000001450296656__p98819237454">Return type: XML</p>
</div>
<div class="section" id="EN-US_TOPIC_0000001450296656__section319114335107"><h4 class="sectiontitle">database_to_xml_and_xmlschema(nulls boolean, tableforest boolean, targetns text)</h4><p id="EN-US_TOPIC_0000001450296656__p9881423124514">Description: Maps database tables to XML values and schema documents.</p>
<p id="EN-US_TOPIC_0000001450296656__p1069723751016">Return type: XML</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0067.html">XML Functions</a></div>
</div>
</div>