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>
65 lines
6.8 KiB
HTML
65 lines
6.8 KiB
HTML
<a name="dli_spark_rpad"></a><a name="dli_spark_rpad"></a>
|
|
|
|
<h1 class="topictitle1">rpad</h1>
|
|
<div id="body8662426"><p id="dli_spark_rpad__en-us_topic_0000001696219561_p011317973211">This function is used to right pad <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b16307175215013">str1</strong> with <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b848316550011">str2</strong> to the specified length.</p>
|
|
<div class="section" id="dli_spark_rpad__en-us_topic_0000001696219561_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_rpad__en-us_topic_0000001696219561_screen119311955101014">rpad(string <str1>, int <length>, string <str2>)</pre>
|
|
</div>
|
|
<div class="section" id="dli_spark_rpad__en-us_topic_0000001696219561_section992014913317"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_rpad__en-us_topic_0000001696219561_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="dli_spark_rpad__en-us_topic_0000001696219561_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="19.220000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_spark_rpad__en-us_topic_0000001696219561_p983074711252">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="13.420000000000002%" id="mcps1.3.3.2.2.5.1.2"><p id="dli_spark_rpad__en-us_topic_0000001696219561_p6830124732517">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="15.590000000000002%" id="mcps1.3.3.2.2.5.1.3"><p id="dli_spark_rpad__en-us_topic_0000001696219561_p13318164512614">Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="51.77%" id="mcps1.3.3.2.2.5.1.4"><p id="dli_spark_rpad__en-us_topic_0000001696219561_p08301547132513">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_spark_rpad__en-us_topic_0000001696219561_row199266231004"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p1084712712254">str1</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p1937912389241">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p183791038192411">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p289944371113">String to be right-padded</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_spark_rpad__en-us_topic_0000001696219561_row2826191220118"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p1382631201120">length</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p14826312111113">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p18826101211118">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p18826112201110">Number of digits to be padded to the right</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_spark_rpad__en-us_topic_0000001696219561_row459281015114"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p45931010191113">str2</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p35936104113">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p10593151011116">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_rpad__en-us_topic_0000001696219561_p155931510131113">String used for padding</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_spark_rpad__en-us_topic_0000001696219561_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_rpad__en-us_topic_0000001696219561_p2407161271219">The return value is of the STRING type.</p>
|
|
<div class="note" id="dli_spark_rpad__en-us_topic_0000001696219561_note61422099395"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dli_spark_rpad__en-us_topic_0000001696219561_ul183121847131216"><li id="dli_spark_rpad__en-us_topic_0000001696219561_li193121947171211">If the value of <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b1171233098112435">length</strong> is smaller than the number of digits in <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b1286075999112435">str1</strong>, the string whose length is truncated from the left of str1 is returned.</li><li id="dli_spark_rpad__en-us_topic_0000001696219561_li163121947191211">If the value of <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b1594216019112450">length</strong> is <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b1131157242112450">0</strong>, an empty string is returned.</li><li id="dli_spark_rpad__en-us_topic_0000001696219561_li153121847161217">If there is no input parameter or the value of any input parameter is <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b309267258112520">NULL</strong>, <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b2065661759112520">NULL</strong> is returned.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="dli_spark_rpad__en-us_topic_0000001696219561_section13277192233920"><h4 class="sectiontitle">Example Code</h4><p id="dli_spark_rpad__en-us_topic_0000001696219561_p161568592318">The value <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b14246205919112">hi???</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_rpad__en-us_topic_0000001696219561_screen1092193292317">SELECT rpad('hi', 5, '??');</pre>
|
|
<p id="dli_spark_rpad__en-us_topic_0000001696219561_p715612513235">The value <strong id="dli_spark_rpad__en-us_topic_0000001696219561_b1555851714218">h</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_rpad__en-us_topic_0000001696219561_screen19120639192310">SELECT rpad('hi', 1, '??');</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0472.html">String Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|