forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
35 lines
3.3 KiB
HTML
35 lines
3.3 KiB
HTML
<a name="dli_08_0357"></a><a name="dli_08_0357"></a>
|
|
|
|
<h1 class="topictitle1">split_cursor</h1>
|
|
<div id="body8662426"><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p189103120151">The <strong id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_b186871822185817">split_cursor</strong> function can convert one row of records into multiple rows or convert one column of records into multiple columns. Table-valued functions can only be used in JOIN LATERAL TABLE.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_table2519181442813" frame="border" border="1" rules="all"><caption><b>Table 1 </b>split_cursor function</caption><thead align="left"><tr id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_row2051971410287"><th align="left" class="cellrowborder" valign="top" width="33%" id="mcps1.3.2.2.4.1.1"><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p6153183918287">Function</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="22%" id="mcps1.3.2.2.4.1.2"><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p17155339102819">Return Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="45%" id="mcps1.3.2.2.4.1.3"><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p1515615396285">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_row125194143283"><td class="cellrowborder" valign="top" width="33%" headers="mcps1.3.2.2.4.1.1 "><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p19519114162816">split_cursor(value, delimiter)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="22%" headers="mcps1.3.2.2.4.1.2 "><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p17519314182816">cursor</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="45%" headers="mcps1.3.2.2.4.1.3 "><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p237225620283">Separates the "value" string into multiple rows of strings by using the delimiter.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section" id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_section111851752184413"><h4 class="sectiontitle">Example</h4><p id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_p129101615154">Input one record ("student1", "student2, student3") and output two records ("student1", "student2") and ("student1", "student3").</p>
|
|
<pre class="screen" id="dli_08_0357__en-us_topic_0000001169022546_en-us_topic_0000001169072352_dli_08_0206_screen14480201913166">create table s1(attr1 string, attr2 string) with (......);
|
|
insert into s2 select attr1, b1 from s1 left join lateral table(split_cursor(attr2, ',')) as T(b1) on true;</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0342.html">Table-Valued Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|