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>
70 lines
8.5 KiB
HTML
70 lines
8.5 KiB
HTML
<a name="dli_spark_lpad"></a><a name="dli_spark_lpad"></a>
|
|
|
|
<h1 class="topictitle1">lpad</h1>
|
|
<div id="body8662426"><p id="dli_spark_lpad__en-us_topic_0000001696219553_p16304151132511">This function is used to return a string of a specified length. If the length of the given string (str1) is shorter than the specified length (length), the given string is left-padded with str2 to the specified length.</p>
|
|
<div class="section" id="dli_spark_lpad__en-us_topic_0000001696219553_section45291954203217"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_spark_lpad__en-us_topic_0000001696219553_screen10637184423619">lpad(string <str1>, int <length>, string <str2>)</pre>
|
|
</div>
|
|
<div class="section" id="dli_spark_lpad__en-us_topic_0000001696219553_section992014913317"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_spark_lpad__en-us_topic_0000001696219553_table1829154762513" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="dli_spark_lpad__en-us_topic_0000001696219553_row8830104792517"><th align="left" class="cellrowborder" valign="top" width="19.220000000000002%" id="mcps1.3.3.2.2.5.1.1"><p id="dli_spark_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_p08301547132513">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_spark_lpad__en-us_topic_0000001696219553_row199266231004"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_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_lpad__en-us_topic_0000001696219553_p99134255019">String to be left-padded</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_spark_lpad__en-us_topic_0000001696219553_row138061989595"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p1445253210254">length</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p1228018496242">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p114011942161215">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p784415518499">Number of digits to be padded to the left</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_spark_lpad__en-us_topic_0000001696219553_row20280174932413"><td class="cellrowborder" valign="top" width="19.220000000000002%" headers="mcps1.3.3.2.2.5.1.1 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p1925812385256">str2</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.420000000000002%" headers="mcps1.3.3.2.2.5.1.2 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p5508183295918">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="15.590000000000002%" headers="mcps1.3.3.2.2.5.1.3 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p14118146151219">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="51.77%" headers="mcps1.3.3.2.2.5.1.4 "><p id="dli_spark_lpad__en-us_topic_0000001696219553_p17481216273">String used for padding</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_spark_lpad__en-us_topic_0000001696219553_section210162513312"><h4 class="sectiontitle">Return Values</h4><p id="dli_spark_lpad__en-us_topic_0000001696219553_p13744143413274">The return value is of the STRING type.</p>
|
|
<div class="note" id="dli_spark_lpad__en-us_topic_0000001696219553_note61422099395"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="dli_spark_lpad__en-us_topic_0000001696219553_ul1378265112713"><li id="dli_spark_lpad__en-us_topic_0000001696219553_li107821151162719">If the value of <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b27588352146">length</strong> is smaller than the number of digits in <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b104011644111412">str1</strong>, the string whose length is truncated from the left of str1 is returned.</li><li id="dli_spark_lpad__en-us_topic_0000001696219553_li67827516279">If the value of <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b2760443172416">length</strong> is <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b12743144520248">0</strong>, an empty string is returned.</li><li id="dli_spark_lpad__en-us_topic_0000001696219553_li1878235117270">If there is no input parameter or the value of any input parameter is <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b13208141062515">NULL</strong>, <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b103467134258">NULL</strong> is returned.</li></ul>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="dli_spark_lpad__en-us_topic_0000001696219553_section13277192233920"><h4 class="sectiontitle">Example Code</h4><ul id="dli_spark_lpad__en-us_topic_0000001696219553_ul16862711172814"><li id="dli_spark_lpad__en-us_topic_0000001696219553_li17862411182812">Uses string <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b010785182617">ZZ</strong> to left pad string <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b181998203261">abcdefgh</strong> to 10 digits. An example command is as follows:<p id="dli_spark_lpad__en-us_topic_0000001696219553_p17332142951213">The value <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b119813632716">ZZabcdefgh</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_lpad__en-us_topic_0000001696219553_screen596923421218">select lpad('abcdefgh', 10, 'ZZ');</pre>
|
|
</li><li id="dli_spark_lpad__en-us_topic_0000001696219553_li13862911102815">Uses string <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b271210182712">ZZ</strong> to left pad string <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b681210162713">abcdefgh</strong> to 5 digits. An example command is as follows:<p id="dli_spark_lpad__en-us_topic_0000001696219553_p1481684119121">The value <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b1896844742719">abcde</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_lpad__en-us_topic_0000001696219553_screen949418464122">select lpad('abcdefgh', 5, 'ZZ');</pre>
|
|
</li><li id="dli_spark_lpad__en-us_topic_0000001696219553_li2862201110280">The value of <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b1980918575275">length</strong> is <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b19987459192719">0</strong>. An example command is as follows:<p id="dli_spark_lpad__en-us_topic_0000001696219553_p733125381210">An empty string is returned.</p>
|
|
<pre class="screen" id="dli_spark_lpad__en-us_topic_0000001696219553_screen1155955714124">select lpad('abcdefgh', 0, 'ZZ'); </pre>
|
|
</li><li id="dli_spark_lpad__en-us_topic_0000001696219553_li98621411132812">The value of any input parameter is <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b207105614563856">NULL</strong>. An example command is as follows:<p id="dli_spark_lpad__en-us_topic_0000001696219553_p467817471315">The value <strong id="dli_spark_lpad__en-us_topic_0000001696219553_b4795825112814">NULL</strong> is returned.</p>
|
|
<pre class="screen" id="dli_spark_lpad__en-us_topic_0000001696219553_screen544413815132">select lpad(null ,0, 'ZZ');</pre>
|
|
</li></ul>
|
|
</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>
|
|
|