forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
159 lines
17 KiB
HTML
159 lines
17 KiB
HTML
<a name="EN-US_TOPIC_0000001188202586"></a><a name="EN-US_TOPIC_0000001188202586"></a>
|
|
|
|
<h1 class="topictitle1">System Functions</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section7403137584"><h4 class="sectiontitle">DAY</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p814041375812">Day</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table1541613105818" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row13140813195812"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p7140171335816"><strong id="EN-US_TOPIC_0000001188202586__b427051313493">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p16140121375812"><strong id="EN-US_TOPIC_0000001188202586__b1429617205499">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row114171375818"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen101411313125817">SELECT DAYS(doj) FROM emp;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen7141513165815">SELECT (TRUNC(doj - TO_DATE('0001/01/01', 'YYYY/MM/DD'))+1) FROM emp;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section1846151325810"><h4 class="sectiontitle">MONTH</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p16141141365816">Month</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table174781375814" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row4141101313583"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p1614191315818"><strong id="EN-US_TOPIC_0000001188202586__b8996615114911">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p714118131582"><strong id="EN-US_TOPIC_0000001188202586__b896602254918">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row1814151311588"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen1614101312589">SELECT (MONTH(ORDER_DATE)-1)/6+1 as TEMP_HY;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen114114134584">SELECT (EXTRACT (MONTH FROM ORDER_DATE) -1)/6+1 as TEMP_HY;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section3511513145819"><h4 class="sectiontitle">YEAR</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p171421139582">Year</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table19521013195819" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row21421113115817"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p1514211138588"><strong id="EN-US_TOPIC_0000001188202586__b165587362496">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p161427131588"><strong id="EN-US_TOPIC_0000001188202586__b8262429144910">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row414231345813"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen814271325810">SELECT YEAR(ORDER_DATE) as TEMP_HY;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen1414261355815">SELECT EXTRACT (YEAR FROM ORDER_DATE) as TEMP_HY;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section75641355819"><h4 class="sectiontitle">CURRENT DATE</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p18142171317583">Current date</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table1457131345810" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row61421513115815"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p101421413145810"><strong id="EN-US_TOPIC_0000001188202586__b119521233194915">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p191428133584"><strong id="EN-US_TOPIC_0000001188202586__b163001231194911">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row18142181365818"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen314214137587">SELECT CURRENT DATE FROM DUAL;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen1214214131588">SELECT CURRENT_DATE FROM DUAL;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section2631113195818"><h4 class="sectiontitle">CURRENT TIMESTAMP</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p19142101314585">Current timestamp</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table664913105819" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row1114251315811"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p8142111365810"><strong id="EN-US_TOPIC_0000001188202586__b173511944508">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p714217137589"><strong id="EN-US_TOPIC_0000001188202586__b086471935017">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row7142131314588"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen2142813195816">SELECT CURRENT TIMESTAMP - 7 DAYS;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen1314220135580">SELECT CURRENT_TIMESTAMP - 7 DAYS;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section26817137581"><h4 class="sectiontitle">POSSTR</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p6142013165812">POSSTR</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table169141317587" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row7142313105820"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p11422013165815"><strong id="EN-US_TOPIC_0000001188202586__b10669167145013">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p6142413175817"><strong id="EN-US_TOPIC_0000001188202586__b17771018145011">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row8142161314589"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen61421813145820">SELECT POSSTR('THIS IS TEST','TEST') FROM DUAL;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen514314136584">SELECT INSTR('THIS IS TEST','TEST') FROM DUAL;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section14731913135812"><h4 class="sectiontitle">VALUE</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p12143171385813">Value</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table774101317584" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row20143161375815"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.7.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p5143181395815"><strong id="EN-US_TOPIC_0000001188202586__b52482133507">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.7.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p12143171345811"><strong id="EN-US_TOPIC_0000001188202586__b1082013157507">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row7143121335818"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.7.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen16143151311583">Select VALUE('abc','') from dual;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.7.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen61437133588">Select Coalesce('abc','') from dual;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_section361619404532"><h4 class="sectiontitle">Date</h4><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p466113407532">The <strong id="EN-US_TOPIC_0000001188202586__b1836968115112">date</strong> function returns a date using a value.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_table3619164020538" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row19661440155312"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p1666134085316"><strong id="EN-US_TOPIC_0000001188202586__b1296015665019">DB2 Syntax</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_p16615409536"><strong id="EN-US_TOPIC_0000001188202586__b113999095120">Syntax After Migration</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_row166611140155310"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen3661204075312">SELECT org_code, DATE(order_date)
|
|
FROM view_cc_order
|
|
WHERE order_date = DATE((SELECT start_date FROM year_week_mark
|
|
WHERE year=TEMP_YEAR and week=TEMP_WEEK));
|
|
---
|
|
SELECT deptno, deptname, DATE(SELECT max(doj) FROM emp e WHERE e.deptno = d.deptno)
|
|
FROM dept d;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202586__en-us_topic_0238518459_en-us_topic_0237362149_en-us_topic_0213529187_screen26617408533">SELECT org_code, mig_db2_ext.mig_db2_fn_date(order_date)
|
|
FROM view_cc_order
|
|
WHERE order_date = mig_db2_ext.mig_db2_fn_date((SELECT start_date FROM year_week_mark
|
|
WHERE year=TEMP_YEAR and week=TEMP_WEEK));
|
|
---
|
|
SELECT deptno, deptname, mig_db2_ext.mig_db2_fn_date((SELECT max(doj) FROM emp e WHERE e.deptno = d.deptno))
|
|
FROM dept d;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_07_0684.html">DB2 Syntax Migration</a></div>
|
|
</div>
|
|
</div>
|
|
|