forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
146 lines
9.4 KiB
HTML
146 lines
9.4 KiB
HTML
<a name="EN-US_TOPIC_0000001819416185"></a><a name="EN-US_TOPIC_0000001819416185"></a>
|
|
|
|
<h1 class="topictitle1">Teradata Formats</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_section57838262517"><h4 class="sectiontitle">Date in the YYYYMMDD Format</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_table584475133312" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row1845125118331"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.2.1.3.1.1"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p115601841545"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b135601440544">Input</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.2.1.3.1.2"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p856014435410"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b1056014416542">Output</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row1184555163312"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen10124266396">SELECT 1 FROM tb_dt_fmtyyyymmdd
|
|
WHERE JobName ='${JOB_NAME}'
|
|
AND TXDATE = ${TX_DATE} - 19000000;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen1198213133913">SELECT 1 FROM tb_dt_fmtyyyymmdd
|
|
WHERE JobName ='${JOB_NAME}'
|
|
AND TXDATE = TO_DATE(${TX_DATE}, 'YYYYMMDD');</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_section6118144252919"><h4 class="sectiontitle">Date in the YYYYDDD Format</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_table983429548" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row8834169840"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.2.1.3.1.1"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p1365237274"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b3651337476">Input</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.2.1.3.1.2"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p146519379717"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b13656371978">Output</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row98351391041"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen224585915176">REPLACE VIEW SC.VIEW_1
|
|
(
|
|
col_1
|
|
)
|
|
LOCKING TABLE sc.tab FOR ACCESS
|
|
AS
|
|
SEL
|
|
--tgt.col_1 is date type
|
|
CAST( CAST(TGT.col_1 AS DATE FORMAT 'YYYYDDD') AS CHAR(7) ) AS col_1
|
|
FROM
|
|
sc.tab TGT
|
|
;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen18245135971719">CREATE
|
|
OR REPLACE VIEW SC.VIEW_1 (col_1)
|
|
/*LOCKING TABLE sc.tab FOR ACCESS */
|
|
AS (
|
|
SELECT
|
|
/* tgt.col_1 is date type */
|
|
CAST( TO_DATE(TGT.col_1, 'YYYYDDD') AS CHAR( 7 ) ) AS col_1
|
|
FROM
|
|
sc.tab TGT
|
|
) ;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_section11305174511305"><h4 class="sectiontitle">Column Names Starting with #</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_table175113355518" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row1175193511517"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.2.1.3.1.1"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p256273915718"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b25622392078">Input</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.2.1.3.1.2"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p556215391777"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b1956253916711">Output</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row13752113511518"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen5380135114171">REPLACE VIEW SC.VIEW_1
|
|
(
|
|
,col_1
|
|
,#_col_2
|
|
,#_col_3
|
|
)
|
|
LOCKING TABLE sc.tab FOR ACCESS
|
|
AS
|
|
SEL
|
|
Tgt.col1
|
|
,Tgt.#_col_2
|
|
,Tgt.#_col_3
|
|
FROM
|
|
sc.tab TGT
|
|
;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen123801851101712">CREATE
|
|
OR REPLACE VIEW SC.VIEW_1 (
|
|
,col_1
|
|
,"#_COL_2"
|
|
,"#_COL_3"
|
|
) /*LOCKING TABLE sc.tab FOR ACCESS */
|
|
AS (
|
|
SELECT
|
|
Tgt.col1
|
|
,Tgt."#_COL_2"
|
|
,Tgt."#_COL_3"
|
|
FROM
|
|
sc.tab TGT
|
|
) ;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_section373389194413"><h4 class="sectiontitle">Database Operations First During Type Casting</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_table4597183914610" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row659783919616"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.2.1.3.1.1"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p832715431777"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b193275434718">Input</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.2.1.3.1.2"><p id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_p13276432070"><strong id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_b93271043879">Output</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_row55975397614"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen1315417430174">REPLACE VIEW SC.VIEW_1
|
|
(
|
|
col_1
|
|
)
|
|
LOCKING TABLE sc.tab FOR ACCESS
|
|
AS
|
|
SEL
|
|
(COALESCE(TRIM(TGT.col_1),'')) || '_' || (COALESCE(TRIM(TGT.col_1),'')) (CHAR(22)) AS col_1
|
|
FROM
|
|
sc.tab TGT
|
|
;</pre>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001819416185__en-us_topic_0000001657865422_en-us_topic_0000001434750229_screen7154144315174">CREATE
|
|
OR REPLACE VIEW SC.VIEW_1 (col_1)
|
|
/*LOCKING TABLE sc.tab FOR ACCESS */
|
|
AS (
|
|
SELECT
|
|
CAST(
|
|
( COALESCE( TRIM( TGT.col_1 ) ,'' ) ) || '_' || ( COALESCE( TRIM( TGT.col_1 ) ,'' ) )
|
|
AS CHAR( 22 ) ) AS col_1
|
|
FROM
|
|
sc.tab TGT
|
|
) ;</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_16_0036.html">Teradata Syntax Migration</a></div>
|
|
</div>
|
|
</div>
|
|
|