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>
438 lines
48 KiB
HTML
438 lines
48 KiB
HTML
<a name="dli_08_0428"></a><a name="dli_08_0428"></a>
|
|
|
|
<h1 class="topictitle1">String Functions</h1>
|
|
<div id="body8662426">
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0428__en-us_topic_0000001310215805_table157276446018" frame="border" border="1" rules="all"><caption><b>Table 1 </b>String Functions</caption><thead align="left"><tr id="dli_08_0428__en-us_topic_0000001310215805_row37271844501"><th align="left" class="cellrowborder" valign="top" width="25.032503250325032%" id="mcps1.3.1.2.4.1.1"><p id="dli_08_0428__en-us_topic_0000001310215805_p67275447010">Function</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="12.51125112511251%" id="mcps1.3.1.2.4.1.2"><p id="dli_08_0428__en-us_topic_0000001310215805_p3728104420012">Return Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="62.456245624562456%" id="mcps1.3.1.2.4.1.3"><p id="dli_08_0428__en-us_topic_0000001310215805_p572814446017">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0428__en-us_topic_0000001310215805_row572817446015"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p172815447010">string1 || string2</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p137285441002">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p07280441902">Returns the concatenation of string1 and string2.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row177282443011"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1026211391339">CHAR_LENGTH(string)</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p11262639430">CHARACTER_LENGTH(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p372814416016">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p97281744100">Returns the number of characters in the string.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1772811447012"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17281744507">UPPER(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p07280449013">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p572817441804">Returns the string in uppercase.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row167281944906"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p10728184420012">LOWER(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p9728244706">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p177289445018">Returns the string in lowercase.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row372816441301"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p11728164416019">POSITION(string1 IN string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p77281844401">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p67288449011">Returns the position (start from <strong id="dli_08_0428__en-us_topic_0000001310215805_b154416476944647">1</strong>) of the first occurrence of string1 in string2; returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b57371314444647">0</strong> if string1 cannot be found in string2.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row3728104412014"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p772824412011">TRIM([ BOTH | LEADING | TRAILING ] string1 FROM string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1972844420014">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p6728244505">Returns a string that removes leading and/or trailing characters string2 from string1.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1728944201"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p19728104418020">LTRIM(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p5728844406">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1728944409">Returns a string that removes the left whitespaces from the specified string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p82974538186">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b29646867444647">LTRIM(' This is a test String.')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b132525499544647">"This is a test String."</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row972874413017"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1972844412018">RTRIM(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p12728194411018">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p37281344801">Returns a string that removes the right whitespaces from the specified string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1521217312190">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b115889396444647">RTRIM('This is a test String.</strong> <strong id="dli_08_0428__en-us_topic_0000001310215805_b138534020244647">')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b157511046144647">"This is a test String."</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row27289441503"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p37285441007">REPEAT(string, integer)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1272812441909">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p872811440011">Returns a string that repeats the base string integer times.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p7210175091916">For example,<strong id="dli_08_0428__en-us_topic_0000001310215805_b94761368144647"> REPEAT('This is a test String.', 2)</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b60460857944647">"This is a test String.This is a test String."</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row67281944704"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p207284441013">REGEXP_REPLACE(string1, string2, string3)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1272812441507">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p872812441305">Returns a string from string1 with all the substrings that match a regular expression string2 consecutively being replaced with string3. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p14026272213">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b209638782844647">REGEXP_REPLACE('foobar', 'oo|ar', '')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b87122637544647">"fb"</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p3409145416323"><strong id="dli_08_0428__en-us_topic_0000001310215805_b73845868444647">REGEXP_REPLACE('ab\ab', '\\', 'e')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b101620411644647">"abeab"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row15728124416017"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p2728144904">OVERLAY(string1 PLACING string2 FROM integer1 [ FOR integer2 ])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p18728114413016">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p14728144415012">Returns a string that replaces integer2 characters of STRING1 with STRING2 from position integer1.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p966853733115">The default value of integer2 is the length of string2.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1097311352710">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b114349199044647">OVERLAY('This is an old string' PLACING ' new' FROM 10 FOR 5)</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b29546157144647">"This is a new string"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1372812441109"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p18728104412014">SUBSTRING(string FROM integer1 [ FOR integer2 ])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p87281744700">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p97289441507">Returns a substring of the specified string starting from position integer1 with length integer2 (to the end by default). If integer2 is not configured, the substring from integer1 to the end is returned by default.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row07286441306"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p157284441703">REPLACE(string1, string2, string3)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1472812445018">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p6728154412011">Returns a new string which replaces all the occurrences of string2 with string3 (non-overlapping) from string1.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p03481855101017">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b203850302644647">REPLACE('hello world', 'world', 'flink')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b27881180244647">"hello flink"</strong>; <strong id="dli_08_0428__en-us_topic_0000001310215805_b65606099044647">REPLACE('ababab', 'abab', 'z')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b64793167544647">"zab"</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p844418502319"><strong id="dli_08_0428__en-us_topic_0000001310215805_b157100778844647">REPLACE('ab\\ab', '\\', 'e')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b208832299444647">"abeab"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row187281944704"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p10728124416019">REGEXP_EXTRACT(string1, string2[, integer])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p15728744109">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1330820184160">Returns a string from string1 which extracted with a specified regular expression string2 and a regex match group index integer.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p538219316497">Returns NULL, if the parameter is NULL or the regular expression is invalid.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p032416246493">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b87604466844647">REGEXP_EXTRACT('foothebar', 'foo(.*?)(bar)', 2)"</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b186251713844647">"bar"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row9728164419015"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p5728044401">INITCAP(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p57286442016">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p67281544209">Returns a new form of STRING with the first character of each word converted to uppercase and the rest characters to lowercase.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1872834415020"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p117286441203">CONCAT(string1, string2,...)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p18728154417019">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p19728944504">Returns a string that concatenates string1, string2, …. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p2085211371979">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b83239847644647">CONCAT('AA', 'BB', 'CC')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b40903564144647">"AABBCC"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row372816441014"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17282441909">CONCAT_WS(string1, string2, string3,...)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272816441809">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p972812441303">Returns a string that concatenates string2, string3, … with a separator string1. The separator is added between the strings to be concatenated. Returns NULL if string1 is NULL. If other arguments are NULL, this function automatically skips NULL arguments.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p33691214131015">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b140934943244647">CONCAT_WS('~', 'AA', NULL, 'BB', '', 'CC')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b37645717744647">"AA~BB~~CC"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row07281344400"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p9728184411019">LPAD(string1, integer, string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p9728144411011">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p107282446015">Returns a new string from string1 left-padded with string2 to a length of integer characters.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1493643132815">If any argument is NULL, NULL is returned.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1814629122716">If integer is negative, NULL is returned.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p14217132292712">If the length of string1 is shorter than integer, returns string1 shortened to integer characters.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p170901815251">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b71970193944647">LPAD(Symbol,4,Symbol)</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b142556718444647">"Symbol hi"</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1219514702415"><strong id="dli_08_0428__en-us_topic_0000001310215805_b197362669244647">LPAD('hi',1,'??')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b96383908744647">"h"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row167281644204"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p147283441400">RPAD(string1, integer, string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p572816441006">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p13287152943014">Returns a new string from string1 right-padded with string2 to a length of integer characters.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1228782912300">If any argument is NULL, NULL is returned.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1328714299301">If integer is negative, NULL is returned.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p928719295308">If the length of string1 is shorter than integer, returns string1 shortened to integer characters.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1528742943013">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b113655731544647">RPAD('hi',4,'??')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b19764015044647">"hi??"</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1019613449318"><strong id="dli_08_0428__en-us_topic_0000001310215805_b209308871444647">RPAD('hi',1,'??')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b42412978644647">"h"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row14728134415016"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p117287441401">FROM_BASE64(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p11728194418013">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1572810441202">Returns the base64-decoded result from string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p138131118164317">Returns NULL if string is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p16453111084217">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b69329155544647">FROM_BASE64('aGVsbG8gd29ybGQ=')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b96077198144647">"hello world"</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row10728164416017"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p167287441404">TO_BASE64(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p372864415011">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p372814441201">Returns the base64-encoded result from string; f string is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p10897153414438">Returns NULL if string is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p162871644184312">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b148731646444647">TO_BASE64(hello world)</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b132993818044647">"aGVsbG8gd29ybGQ="</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row672884415015"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p37288441012">ASCII(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1972816441209">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17728114416014">Returns the numeric value of the first character of string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p214510111457">Returns NULL if string is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p9317123614450">For example, <strong id="dli_08_0428__en-us_topic_0000001310215805_b155636027044647">ascii('abc')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b176551555844647">97.</strong></p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1915813571449"><strong id="dli_08_0428__en-us_topic_0000001310215805_b121953118844647">ascii(CAST(NULL AS VARCHAR))</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b68113926344647">NULL</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row117283443010"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p072817447019">CHR(integer)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p15728104413013">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p177288444011">Returns the ASCII character having the binary equivalent to integer.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p2301711125813">If integer is larger than 255, we will get the modulus of integer divided by 255 first, and returns CHR of the modulus.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p16350165015564">Returns NULL if integer is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p6952201812574"><strong id="dli_08_0428__en-us_topic_0000001310215805_b53397845444647">chr(97)</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b50906958344647">a</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1730216378574"><strong id="dli_08_0428__en-us_topic_0000001310215805_b113302087544647">chr(353)</strong> Return <strong id="dli_08_0428__en-us_topic_0000001310215805_b44816630644647">a</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row127281644306"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p15729104415012">DECODE(binary, string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p147295442012">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p197291744204">Decodes the first argument into a String using the provided character set (one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16').</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p445234002418">If either argument is NULL, the result will also be NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row3729144418012"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p207291244801">ENCODE(strinh1, string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p472913443015">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p2526123802516">Encodes the string1 into a BINARY using the provided string2 character set (one of 'US-ASCII', 'ISO-8859-1', 'UTF-8', 'UTF-16BE', 'UTF-16LE', 'UTF-16').</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p672912441706">If either argument is NULL, the result will also be NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row11729144419019"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p67293443013">INSTR(string1, string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p167295444018">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p15729114417012">Returns the position of the first occurrence of string2 in string1.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p107541418122">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row187295441709"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p157295441905">LEFT(string, integer)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p7729644708">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272912440016">Returns the leftmost integer characters from the string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1972833211414">Returns EMPTY String if integer is negative.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1825584411148">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row177294441503"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p0729164418012">RIGHT(string, integer)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p3729644309">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p87293441013">Returns the rightmost integer characters from the string.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1938635416165">Returns EMPTY String if integer is negative.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p878384791714">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1172915445013"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p14729164412019">LOCATE(string1, string2[, integer])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p472910441903">INT</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272912441502">Returns the position of the first occurrence of string1 in string2 after position integer.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p222413015196">Returns 0 if not found. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1026133782210">The value of <strong id="dli_08_0428__en-us_topic_0000001310215805_b183716212386">integer</strong> defaults to <strong id="dli_08_0428__en-us_topic_0000001310215805_b93772183813">0</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p17091550181916">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row07296445012"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p27295447014">PARSE_URL(string1, string2[, string3])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1072915448010">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p672918446014">Returns the specified part from the URL. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p51612207261">Valid values for string2 include 'HOST', 'PATH', 'QUERY', 'REF', 'PROTOCOL', 'AUTHORITY', 'FILE', and 'USERINFO'. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p111411509263">Returns NULL if any argument is NULL.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p59271535285">If string2 is QUERY, the key in QUERY can be specified as string3.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p79261934182718">Example:</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p160105642716">The <strong id="dli_08_0428__en-us_topic_0000001310215805_b128969590444647">parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'HOST')</strong> returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b176106092944647">'facebook.com'</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p19193872714"><strong id="dli_08_0428__en-us_topic_0000001310215805_b163319687244647">parse_url('http://facebook.com/path1/p.php?k1=v1&k2=v2#Ref1', 'QUERY', 'k1')</strong> <strong id="dli_08_0428__en-us_topic_0000001310215805_b33037455444647">returns 'v1'</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1672910447020"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272934420010">REGEXP(string1, string2)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1572915441305">BOOLEAN</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p572914418015">Performs a regular expression search on the specified string and returns a BOOLEAN value indicating whether the specified match pattern is found. If it is found, TRUE is returned. string1 indicates the specified string, and string2 indicates the regular expression.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p666033803113">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row272915447012"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272974413016">REVERSE(string)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p127295449013">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17729944305">Returns the reversed string. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p95241645133413">Returns NULL if any argument is NULL.</p>
|
|
<div class="note" id="dli_08_0428__en-us_topic_0000001310215805_note11553531191"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="dli_08_0428__en-us_topic_0000001310215805_p8566531493">Note that backquotes must be added to this function, for example, `REVERSE`.</p>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1972918444018"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1172918443014">SPLIT_INDEX(string1, string2, integer1)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p177296449015">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17729244305">Splits string1 by the delimiter string2, returns the integerth (zero-based) string of the split strings. Returns NULL if integer is negative.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p7990114610375">Returns NULL if integer is negative. </p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p2256155903715">Returns NULL if any argument is NULL.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1872915441908"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1972915446018">STR_TO_MAP(string1[, string2, string3]])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p0729644705">MAP</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p272964411011">Returns a map after splitting the string1 into key/value pairs using delimiters.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p8293257124320">The default value of string2 is <strong id="dli_08_0428__en-us_topic_0000001310215805_b107799165344647">','</strong>.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p1583019410442">The default value of string3 is <strong id="dli_08_0428__en-us_topic_0000001310215805_b43745662244647">'='</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row772914441006"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p177291444403">SUBSTR(string[, integer1[, integer2]])</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p872944417016">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p13729444605">Returns a substring of string starting from position integer1 with length integer2.</p>
|
|
<p id="dli_08_0428__en-us_topic_0000001310215805_p151491950154510">If integer2 is not specified, the string is truncated to the end.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row9608134018219"><td class="cellrowborder" valign="top" width="25.032503250325032%" headers="mcps1.3.1.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1761014299223">JSON_VAL(STRING json_string, STRING json_path)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="12.51125112511251%" headers="mcps1.3.1.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p146081540182115">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="62.456245624562456%" headers="mcps1.3.1.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p16608124011214">Returns the value of the specified <strong id="dli_08_0428__en-us_topic_0000001310215805_b181930597044647">json_path</strong> from the <strong id="dli_08_0428__en-us_topic_0000001310215805_b38131622744647">json_string</strong>. For details about how to use the functions, see <a href="#dli_08_0428__en-us_topic_0000001310215805_section624613301257">JSON_VAL Function</a>.</p>
|
|
<div class="note" id="dli_08_0428__en-us_topic_0000001310215805_note1734061893313"><span class="notetitle"> NOTE: </span><div class="notebody"><p id="dli_08_0428__en-us_topic_0000001310215805_p129821342161516">The following rules are listed in descending order of priority.</p>
|
|
<ol id="dli_08_0428__en-us_topic_0000001310215805_ol17340154110164"><li id="dli_08_0428__en-us_topic_0000001310215805_li193401041191618">The two arguments <strong id="dli_08_0428__en-us_topic_0000001310215805_b22970223544647">json_string</strong> and <strong id="dli_08_0428__en-us_topic_0000001310215805_b202179959044647">json_path</strong> cannot be <strong id="dli_08_0428__en-us_topic_0000001310215805_b14964441844647">NULL</strong>.</li><li id="dli_08_0428__en-us_topic_0000001310215805_li722714431619">The value of <strong id="dli_08_0428__en-us_topic_0000001310215805_b35101945344647">json_string</strong> must be a valid JSON string. Otherwise, the function returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b54959067044647">NULL</strong>.</li><li id="dli_08_0428__en-us_topic_0000001310215805_li1037194611610">If <strong id="dli_08_0428__en-us_topic_0000001310215805_b179330553344647">json_string</strong> is an empty string, the function returns an empty string.</li><li id="dli_08_0428__en-us_topic_0000001310215805_li837174816163">If <strong id="dli_08_0428__en-us_topic_0000001310215805_b141077722944647">json_path</strong> is an empty string or the path does not exist, the function returns <strong id="dli_08_0428__en-us_topic_0000001310215805_b546916344647">NULL</strong>.</li></ol>
|
|
</div></div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section" id="dli_08_0428__en-us_topic_0000001310215805_section624613301257"><a name="dli_08_0428__en-us_topic_0000001310215805_section624613301257"></a><a name="en-us_topic_0000001310215805_section624613301257"></a><h4 class="sectiontitle">JSON_VAL Function</h4><ul id="dli_08_0428__en-us_topic_0000001310215805_ul149287348263"><li id="dli_08_0428__en-us_topic_0000001310215805_li15929153422616">Syntax</li></ul>
|
|
<pre class="screen" id="dli_08_0428__en-us_topic_0000001310215805_screen112231124142612">STRING JSON_VAL(STRING json_string, STRING json_path)</pre>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0428__en-us_topic_0000001310215805_table343016642713" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Parameters</caption><thead align="left"><tr id="dli_08_0428__en-us_topic_0000001310215805_row843114615273"><th align="left" class="cellrowborder" valign="top" width="20.782078207820785%" id="mcps1.3.2.4.2.4.1.1"><p id="dli_08_0428__en-us_topic_0000001310215805_p1643176142717">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="26.632663266326627%" id="mcps1.3.2.4.2.4.1.2"><p id="dli_08_0428__en-us_topic_0000001310215805_p164312682715">Data Types</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="52.58525852585259%" id="mcps1.3.2.4.2.4.1.3"><p id="dli_08_0428__en-us_topic_0000001310215805_p143111662712">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0428__en-us_topic_0000001310215805_row6431767278"><td class="cellrowborder" valign="top" width="20.782078207820785%" headers="mcps1.3.2.4.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p154315611276">json_string</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.632663266326627%" headers="mcps1.3.2.4.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p17431166102716">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.58525852585259%" headers="mcps1.3.2.4.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p194311463278">JSON object to be parsed</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row943118619270"><td class="cellrowborder" valign="top" width="20.782078207820785%" headers="mcps1.3.2.4.2.4.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p13431156192714">json_path</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="26.632663266326627%" headers="mcps1.3.2.4.2.4.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p84318620278">STRING</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.58525852585259%" headers="mcps1.3.2.4.2.4.1.3 "><p id="dli_08_0428__en-us_topic_0000001310215805_p14431166182710">Path expression for parsing the JSON string For the supported expressions, see <a href="#dli_08_0428__en-us_topic_0000001310215805_table147467547297">Table 3</a>.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="tablenoborder"><a name="dli_08_0428__en-us_topic_0000001310215805_table147467547297"></a><a name="en-us_topic_0000001310215805_table147467547297"></a><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0428__en-us_topic_0000001310215805_table147467547297" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Expressions supported</caption><thead align="left"><tr id="dli_08_0428__en-us_topic_0000001310215805_row1874615549294"><th align="left" class="cellrowborder" valign="top" width="44.04%" id="mcps1.3.2.5.2.3.1.1"><p id="dli_08_0428__en-us_topic_0000001310215805_p7746155412914">Expression</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="55.96%" id="mcps1.3.2.5.2.3.1.2"><p id="dli_08_0428__en-us_topic_0000001310215805_p7746135413292">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_0428__en-us_topic_0000001310215805_row1574625472912"><td class="cellrowborder" valign="top" width="44.04%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1074655417299">$</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.96%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p107461354122914">Root node in the path</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row1746135452912"><td class="cellrowborder" valign="top" width="44.04%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p5746165472913">[]</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.96%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1374675492914">Access array elements</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row474645418294"><td class="cellrowborder" valign="top" width="44.04%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p3746155492914">*</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.96%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p14746145482919">Array wildcard</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_0428__en-us_topic_0000001310215805_row480105719316"><td class="cellrowborder" valign="top" width="44.04%" headers="mcps1.3.2.5.2.3.1.1 "><p id="dli_08_0428__en-us_topic_0000001310215805_p1080165716311">.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="55.96%" headers="mcps1.3.2.5.2.3.1.2 "><p id="dli_08_0428__en-us_topic_0000001310215805_p980757183119">Access child elements</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<ul id="dli_08_0428__en-us_topic_0000001310215805_ul141132115517"><li id="dli_08_0428__en-us_topic_0000001310215805_li911821255">Example<ol id="dli_08_0428__en-us_topic_0000001310215805_ol932913554614"><li id="dli_08_0428__en-us_topic_0000001310215805_li193291255367">Test input data.<div class="p" id="dli_08_0428__en-us_topic_0000001310215805_p1090101315812"><a name="dli_08_0428__en-us_topic_0000001310215805_li193291255367"></a><a name="en-us_topic_0000001310215805_li193291255367"></a>Test the data source kafka. The message content is as follows:<pre class="screen" id="dli_08_0428__en-us_topic_0000001310215805_screen193101913486">{name:James,age:24,sex:male,grade:{math:95,science:[80,85],english:100}}
|
|
{name:James,age:24,sex:male,grade:{math:95,science:[80,85],english:100}<strong id="dli_08_0428__en-us_topic_0000001310215805_b1447018465392">]</strong></pre>
|
|
</div>
|
|
</li><li id="dli_08_0428__en-us_topic_0000001310215805_li1535210201774">Use JSON_VAL in SQL statements.<pre class="screen" id="dli_08_0428__en-us_topic_0000001310215805_screen32774318814">CREATE TABLE kafkaSource (
|
|
`message` string
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = '<yourSourceTopic>',
|
|
'properties.bootstrap.servers' = '<yourKafkaAddress1>:<yourKafkaPort>,<yourKafkaAddress2>:<yourKafkaPort>',
|
|
'properties.group.id' = '<yourGroupId>',
|
|
'scan.startup.mode' = 'latest-offset',
|
|
"format" = "csv",
|
|
"csv.field-delimiter" = "\u0001",
|
|
"csv.quote-character" = "''"
|
|
);
|
|
|
|
CREATE TABLE kafkaSink(
|
|
message1 STRING,
|
|
message2 STRING,
|
|
message3 STRING,
|
|
message4 STRING,
|
|
message5 STRING,
|
|
message6 STRING
|
|
) WITH (
|
|
'connector' = 'kafka',
|
|
'topic' = '<yourSinkTopic>',
|
|
'properties.bootstrap.servers' = '<yourKafkaAddress1>:<yourKafkaPort>,<yourKafkaAddress2>:<yourKafkaPort>',
|
|
"format" = "json"
|
|
);
|
|
|
|
insert into kafkaSink select
|
|
JSON_VAL(message,""),
|
|
JSON_VAL(message,"$.name"),
|
|
JSON_VAL(message,"$.grade.science"),
|
|
JSON_VAL(message,"$.grade.science[*]"),
|
|
JSON_VAL(message,"$.grade.science[1]"),JSON_VAL(message,"$.grade.dddd")
|
|
from kafkaSource;</pre>
|
|
</li><li id="dli_08_0428__en-us_topic_0000001310215805_li8729420711">Check the output result of the Kafka topic in the sink.<pre class="screen" id="dli_08_0428__en-us_topic_0000001310215805_screen1742352518914">{"message1":null,"message2":"swq","message3":"[80,85]","message4":"[80,85]","message5":"85","message6":null}
|
|
{"message1":null,"message2":null,"message3":null,"message4":null,"message5":null,"message6":null}</pre>
|
|
</li></ol>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0426.html">Built-In Functions</a></div>
|
|
</div>
|
|
</div>
|
|
|