doc-exports/docs/dws/tool/dws_07_8120.html
Lu, Huayi 346ac31da9 DWS TG 8.1.3.200 VERSION
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>
2023-08-28 09:20:17 +00:00

596 lines
28 KiB
HTML

<a name="EN-US_TOPIC_0000001234200607"></a><a name="EN-US_TOPIC_0000001234200607"></a>
<h1 class="topictitle1">BTEQ Utility Command</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p8906152234810">The BTEQ utility commands are as follows:</p>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section938131511020"><h4 class="sectiontitle">LOGOFF QUIT</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p031836162614">LOGOFF ends the current RDBMS sessions without exiting BTEQ.</p>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p32566457269">QUIT command ends the current Teradata database sessions and exits BTEQ.</p>
</div>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p3631112694019"><strong id="EN-US_TOPIC_0000001234200607__b03467330385">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen194881638114017">SELECT 'StartDTTM' as a
,CURRENT_TIMESTAMP (FORMAT 'HH:MI:SSBMMMBDD,BYYYY') ;
.LOGOFF;
.QUIT;</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p330524819408"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b436613234118">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen1231917817412">SELECT 'StartDTTM' as a
,CURRENT_TIMESTAMP (FORMAT 'HH:MI:SSBMMMBDD,BYYYY') ;
.LOGOFF;
.QUIT;</pre>
<div class="note" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_note29701912124220"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p106341131172713">Gauss does not support, so it is required to comment.</p>
</div></div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section136120191725"><h4 class="sectiontitle">.IF ERRORCODE and .QUIT</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p179321821221">BTEQ statements specified with .IF and .QUIT.</p>
</div>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p181567320220"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1915618315219">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen20156931124">COLLECT STATISTICS
USING SAMPLE 5.00 PERCENT
COLUMN ( CDR_TYPE_KEY ) ,
COLUMN ( PARTITION ) ,
COLUMN ( SRC ) ,
COLUMN ( PARTITION,SBSCRPN_KEY )
ON DT_SDM.FCT_OTGO_NTWK_ACTVY_DAILY ;
</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p41569313210"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b315623024">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen121561631724">SET
default_statistics_target = 5.00 ;
ANALYZE DT_SDM.FCT_OTGO_NTWK_ACTVY_DAILY (CDR_TYPE_KEY) ;
ANALYZE DT_SDM.FCT_OTGO_NTWK_ACTVY_DAILY (PARTITION) ;
ANALYZE DT_SDM.FCT_OTGO_NTWK_ACTVY_DAILY (SRC) ;
ANALYZE DT_SDM.FCT_OTGO_NTWK_ACTVY_DAILY (PARTITION,SBSCRPN_KEY) ;
RESET default_statistics_target ;</pre>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section106641731134915"><h4 class="sectiontitle">.IF</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p43256496183014"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1875971554">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen19749916502">.IF END_MONTH_FLAG &lt;&gt; 'Y' THEN .GOTO LABEL_1; </pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p156331551125015"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b0633751125018">Output:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen19218131611512">IF END_MONTH_FLAG &lt;&gt; 'Y' THEN
GOTO LABEL_1 ;
END IF ;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section2202565516"><h4 class="sectiontitle">.QUIT</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p670181145213"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b67019112524">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen109621526105213">.IF ERRORCODE &lt;&gt; 0 THEN .QUIT 12;</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p949231711524"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b449251735218">Output:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen1873911438527">IF ERRORCODE &lt;&gt; 0 THEN
RAISE EXCEPTION '12' ;
END IF;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section62561812618"><h4 class="sectiontitle">.IF &amp; .QUIT</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p4936161315110">.IF and .QUIT should be moved inside the block.</p>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_table584475133312" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row1845125118331"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.16.1.3.1.1"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p352181464414"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b484515110336">Oracle Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.16.1.3.1.2"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p10681514114419"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b81851635102616">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row1184555163312"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.16.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen125845013219">INSERT INTO EMP
SELECT * FROM EMP;
.IF ERRORCODE &lt;&gt; 0 THEN .QUIT 12;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.16.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen61210445218">DECLARE
lv_mig_errorcode NUMBER ( 4 ) ;
BEGIN
BEGIN
INSERT INTO EMP
SELECT * FROM EMP;
lv_mig_errorcode := 0 ;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode := - 1 ;
END ;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12' ;
END IF ;
END ;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section13215201115312"><h4 class="sectiontitle">.RETURN</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p56951918165316"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b46951818145312">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen169501825315">.if ERRORCODE = 0 then .RETURN; </pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p206951518185311"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b14695918115316">Output:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen8695111815316">IF ERRORCODE = 0 THEN
RETURN;
END IF;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section17518165510536"><h4 class="sectiontitle">.GOTO</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p776514265414"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1176517275411">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen18765132205419">.IF END_MONTH_FLAG &lt;&gt; 'Y' THEN .GOTO LABEL_1; </pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p976516295419"><strong id="EN-US_TOPIC_0000001234200607__b2001924134">Output:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen27651255413">IF END_MONTH_FLAG &lt;&gt; 'Y' THEN
GOTO LABEL_1;
END IF ;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section155536514558"><h4 class="sectiontitle">Label</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p188331151559"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b783481514551">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen0834181516555">.LABEL LABEL_1</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p783411505511"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1283451535511">Output:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen0834141595511">&lt;&lt;LABEL_1&gt;&gt;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section1841012215715"><h4 class="sectiontitle">ERRORCODE 3807</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p449374075"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b18941161918717">Input:</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen398315231378">SELECT end_mon AS END_MONTH_FLAG
FROM tab2 ;
.IF END_MONTH_FLAG &lt;&gt; 'Y' THEN
.GOTO LABEL_1;
.IF ERRORCODE = 3807 THEN
.QUIT 8888;</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p62136111171"><strong id="EN-US_TOPIC_0000001234200607__b1799569044">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen111761627372">DECLARE lv_mig_errorcode NUMBER (4);
lv_mig_END_MONTH_FLAG TEXT;
BEGIN
BEGIN
SELECT end_mon
INTO lv_mig_END_MONTH_FLAG
FROM tab2 ;
lv_mig_errorcode := 0 ;
EXCEPTION
WHEN UNDEFINED_TABLE THEN
lv_mig_errorcode := 3807 ;
WHEN OTHERS THEN
lv_mig_errorcode := - 1 ;
END ;
IF lv_mig_END_MONTH_FLAG &lt;&gt; 'Y' THEN
GOTO LABEL_1 ;
END IF ;
IF lv_mig_errorcode = 3807 THEN
RAISE EXCEPTION '8888' ;
END IF ;
END;
/</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section23844683819"><h4 class="sectiontitle">BT with BTEQ commands</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p683464733811"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b473713416394">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen1244611911395">BT;
delete from ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
where DW_Job_Seq = ${v_Group_No};
.if ERRORCODE &lt;&gt; 0 then .quit 12;
insert into ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
(
Cust_Id
,Cust_UID
,DW_Upd_Dt
,DW_Upd_Tm
,DW_Job_Seq
,DW_Etl_Dt
)
select
a.Cust_Id
,a.Cust_UID
,current_date as Dw_Upd_Dt
,current_time(0) as DW_Upd_Tm
,cast(${v_Group_No} as byteint) as DW_Job_Seq
,cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd') as DW_Etl_Dt
from ${BRTL_VCOR}.BRTL_CS_CUST_CID_UID_REL_S a
where a.DW_Snsh_Dt = cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd');
.if ERRORCODE &lt;&gt; 0 then .quit 12;
</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p1123585711381"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b127414419394">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen127591632164319">BEGIN
--
BEGIN
delete from ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
where DW_Job_Seq = ${v_Group_No};
lv_mig_errorcode = 0;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode = -1;
END;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12';
END IF;</pre>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section17404752104312"><h4 class="sectiontitle">ET with BTEQ Commands</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p965118406913"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1065018217109">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen7847571913">ET;
BEGIN
BEGIN
delete from ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
where DW_Job_Seq = ${v_Group_No};
lv_mig_errorcode = 0;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode = -1;
END;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12';
END IF;
BEGIN
insert into ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
(
Cust_Id
,Cust_UID
,DW_Upd_Dt
,DW_Upd_Tm
,DW_Job_Seq
,DW_Etl_Dt
)
select
a.Cust_Id
,a.Cust_UID
,current_date as Dw_Upd_Dt
,current_time(0) as DW_Upd_Tm
,cast(${v_Group_No} as byteint) as DW_Job_Seq
,cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd') as DW_Etl_Dt
from ${BRTL_VCOR}.BRTL_CS_CUST_CID_UID_REL_S a
where a.DW_Snsh_Dt = cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd');
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode = -1;
END;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12';
END IF;
END;</pre>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p149048431792"><strong id="EN-US_TOPIC_0000001234200607__b1500971928">Output</strong></p>
</div>
<pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen1527800191010">--
BEGIN
insert into ${BRTL_DCOR}.BRTL_CS_CUST_CID_UID_REL
(
Cust_Id
,Cust_UID
,DW_Upd_Dt
,DW_Upd_Tm
,DW_Job_Seq
,DW_Etl_Dt
)
select
a.Cust_Id
,a.Cust_UID
,current_date as Dw_Upd_Dt
,current_time(0) as DW_Upd_Tm
,cast(${v_Group_No} as byteint) as DW_Job_Seq
,cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd') as DW_Etl_Dt
from ${BRTL_VCOR}.BRTL_CS_CUST_CID_UID_REL_S a
where a.DW_Snsh_Dt = cast('${v_Trx_Dt}' as date format 'yyyy-mm-dd');
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode = -1;
END;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12';
END IF;
END;</pre>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section116921983412"><h4 class="sectiontitle">.Export FILE</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p16001225164715">.EXPORT FILE should be changed to COPY and teradata utilities is set to <strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b106971412103616">false</strong>.</p>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_table156417291642" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row356417291442"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.25.1.3.1.1"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p12122133414414"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1956411291447">Oracle Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.25.1.3.1.2"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p112223414440"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b8703813311">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row145642291246"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.25.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen12558115617418">.export file = $FILENAME;
select empno, ename from emp where deptno = 1;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.25.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen13423471656">COPY (select empno, ename from emp where deptno = 1) TO '$FILENAME' CSV HEADER DELIMITER E'\t';</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p63801641488">.EXPORT FILE should be changed to $q$COPY and moved inside the block when teradataUtilities is set to <strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1062593018360">true</strong>.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_table14176411156" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row124177411959"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.27.1.3.1.1"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p13498193610441"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b1941711411253">Oracle Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.27.1.3.1.2"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p1749843614449"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b13569119163113">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row1417641154"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.27.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen1434585612511">print BTEQ &lt;&lt;ENDOFINPUT;
DATABASE HPBUS;
.export file = $FILENAME;
select empno, ename from emp where deptno = 1;
.IF ERRORCODE &lt;&gt; 0 THEN .QUIT 12;
.LOGOFF;
.QUIT 0;
ENDOFINPUT</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.27.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen15889412269">DECLARE lv_mig_obj_exists_check NUMBER(1);
lv_mig_errorcode NUMBER(4);
BEGIN
SET SESSION CURRENT_SCHEMA TO public ;
BEGIN
SELECT COUNT(*) INTO lv_mig_obj_exists_check
FROM (select empno, ename from emp where deptno = 1);
lv_mig_errorcode := 0;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode := -1;
END ;
EXECUTE $q$COPY (select empno, ename from emp where deptno = 1) TO '$FILENAME' CSV HEADER DELIMITER E'\t'$q$;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12';
END IF ;
RAISE EXCEPTION '-99';
RETURN ;
END ;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_section7305131514119"><h4 class="sectiontitle">SQL_Lang &amp; BTEQ</h4><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p18779351819">Multiple tag names should be handled for SQL_Lang.</p>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_table76811451112" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row1969164581111"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.29.1.3.1.1"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p17690455114"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b3699452116">Oracle Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.29.1.3.1.2"><p id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_p1969645131115"><strong id="EN-US_TOPIC_0000001234200607__en-us_topic_0237712274_b15152121183116">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_row8696454119"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.29.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen113103104123">#!/usr/bin/perl
######################################################################
# BTEQ script in Perl
# Date Time : 2013-10-15
# Table : TB_NET_LTE_GPRS_CDR (4G GPRS&raquo;&deg;&micro;&yen;)
# Script Name : XXX00_TB_NET_LTE_GPRS_CDR
# Source Table : TB_04024-GPRS
# Load strategy: S4
use strict; # Declare using Perl strict syntax
my $HOME = $ENV{"AUTO_HOME"};
unshift(@INC, "$HOME/bin");
require etl_pub;
# ------------ Variable Section ------------
# DATABASE NAMES
my $TEMPDB = $ETL::TEMPDB;
my $SDATADB = $ETL::SDATADB;
my $PDATADB = $ETL::PDATADB;
my $PARADB = $ETL::PARADB;
my $PDDL = $ETL::PDDL;
my $PCODE = $ETL::PCODE;
if ( $#ARGV &lt; 0 ) {
exit(1);
}
my $CONTROL_FILE = $ARGV[0];
my $TX_DATE = substr(${CONTROL_FILE},length(${CONTROL_FILE})-12, 8);
open(STDERR, "&gt;&amp;STDOUT");
my $TRG_COL_LIST =&lt;&lt;TRGCOLLIST;
MSISDN
,dat_rcd_dt
,vst_rgn_cd
TRGCOLLIST
my $MAP_COL_LIST =&lt;&lt;MAPCOLLIST;
TB_04024.msisdn
,CAST('$TX_DATE' AS DATE FORMAT 'YYYYMMDD')
,TB_04024.vst_rgn_cd
MAPCOLLIST
my $FILTER = "CMCC_Prov_Prvd_Id=$PCODE";
my $table_today ="${TEMPDB}.TB_04024_${PCODE}";
my $table_target = "Z" . substr($PCODE,1,2) . "NET_LTE_GPRS_CDR";
my $UNIT_FLAG;
sub BTEQ_S4
{
my ($dbh) = @_;
my $BTEQ_CMD_S4 = &lt;&lt;ENDOFINPUT;
INSERT INTO ${PDATADB}.$table_target (
$TRG_COL_LIST)
SELECT
$MAP_COL_LIST
FROM $SDATADB.TB_${PCODE}_04024_${UNIT_FLAG}_${TX_DATE} TB_04024;
.IF ERRORCODE &lt;&gt; 0 THEN .QUIT 12;
ENDOFINPUT
return $BTEQ_CMD_S4;
}
my $unit_num = "04024";
sub BTEQ_Z1
{
my $BTEQ_CMD_Z1 = &lt;&lt;ENDOFINPUT;
INSERT INTO ${PDATADB}.$table_target (
$TRG_COL_LIST)
SELECT
$MAP_COL_LIST
FROM $SDATADB.TB_${PCODE}_${unit_num}_${UNIT_FLAG}_${TX_DATE} tb_${unit_num};
.IF ERRORCODE &lt;&gt; 0 THEN .QUIT 12;
ENDOFINPUT
return $BTEQ_CMD_Z1;
}
sub main()
{
my $dbh=ETL::DBconnect();
# SDATA
$UNIT_FLAG = ETL::get_UNIT_FLAG($dbh, "TB_04024", $PCODE, $TX_DATE);
my $BTEQCMD = "";
if ( $UNIT_FLAG eq " " ) {
print "&Ocirc;!\n";
ETL::disconnectETL($dbh);
return 1;
} elsif ($UNIT_FLAG eq "S") {
$BTEQCMD = BTEQ_S4($dbh);
} elsif ($UNIT_FLAG eq "Z") {
$BTEQCMD = BTEQ_Z1($dbh);
} else {
print "\n";
return 1;
}
ETL::disconnectETL($dbh);
return ETL::ExecuteBTEQ($BTEQCMD, $TX_DATE);
}
my $ret= main();
exit($ret);
</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.29.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001234200607__en-us_topic_0238518371_en-us_topic_0237362269_screen169134512119">#!/usr/bin/perl
######################################################################
# BTEQ script in Perl
# Date Time : 2013-10-15
# Table : TB_NET_LTE_GPRS_CDR (4G GPRS)
# Script Name : XXX00_TB_NET_LTE_GPRS_CDR
# Source Table : TB_04024-GPRS
# Load strategy: S4
use strict; # Declare using Perl strict syntax
my $HOME = $ENV{"AUTO_HOME"};
unshift(@INC, "$HOME/bin");
require etl_pub;
# ------------ Variable Section ------------
# DATABASE NAMES
my $TEMPDB = $ETL::TEMPDB;
my $SDATADB = $ETL::SDATADB;
my $PDATADB = $ETL::PDATADB;
my $PARADB = $ETL::PARADB;
my $PDDL = $ETL::PDDL;
my $PCODE = $ETL::PCODE;
if ( $#ARGV &lt; 0 ) {
exit(1);
}
my $CONTROL_FILE = $ARGV[0];
my $TX_DATE = substr(${CONTROL_FILE},length(${CONTROL_FILE})-12, 8);
open(STDERR, "&gt;&amp;STDOUT");
my $TRG_COL_LIST=&lt;&lt;TRGCOLLIST ;
MSISDN
,dat_rcd_dt
,vst_rgn_cd
TRGCOLLIST
my $MAP_COL_LIST=&lt;&lt;MAPCOLLIST ;
TB_04024.msisdn
,CAST( '$TX_DATE' AS DATE )
,TB_04024.vst_rgn_cd
MAPCOLLIST
my $FILTER = "CMCC_Prov_Prvd_Id=$PCODE";
my $table_today ="${TEMPDB}.TB_04024_${PCODE}";
my $table_target = "Z" . substr($PCODE,1,2) . "NET_LTE_GPRS_CDR";
my $UNIT_FLAG;
sub BTEQ_S4
{
my ($dbh) = @_;
my $BTEQ_CMD_S4=&lt;&lt;ENDOFINPUT ;
DECLARE lv_mig_obj_exists_check NUMBER ( 1 ) ;
lv_mig_errorcode NUMBER ( 4 ) ;
BEGIN
BEGIN
INSERT INTO ${PDATADB}.$table_target ($TRG_COL_LIST)
SELECT
$MAP_COL_LIST
FROM
$SDATADB.TB_${PCODE}_04024_${UNIT_FLAG}_${TX_DATE} TB_04024 ;
lv_mig_errorcode := 0 ;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode := - 1 ;
END ;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12' ;
END IF ;
END ;
/
ENDOFINPUT
return $BTEQ_CMD_S4;
}
my $unit_num = "04024";
sub BTEQ_Z1
{
my $BTEQ_CMD_Z1=&lt;&lt;ENDOFINPUT ;
DECLARE lv_mig_obj_exists_check NUMBER ( 1 ) ;
lv_mig_errorcode NUMBER ( 4 ) ;
BEGIN
INSERT INTO ${PDATADB}.$table_target ($TRG_COL_LIST)
SELECT
$MAP_COL_LIST
FROM
$SDATADB.TB_${PCODE}_${unit_num}_${UNIT_FLAG}_${TX_DATE} tb_${unit_num} ;
lv_mig_errorcode := 0 ;
EXCEPTION
WHEN OTHERS THEN
lv_mig_errorcode := - 1 ;
END ;
IF lv_mig_errorcode &lt;&gt; 0 THEN
RAISE EXCEPTION '12' ;
END IF ;
END ;
/
ENDOFINPUT
return $BTEQ_CMD_Z1;
}
sub main()
{
my $dbh=ETL::DBconnect();
# SDATA
$UNIT_FLAG = ETL::get_UNIT_FLAG($dbh, "TB_04024", $PCODE, $TX_DATE);
my $BTEQCMD = "";
if ( $UNIT_FLAG eq " " ) {
print "!\n";
ETL::disconnectETL($dbh);
return 1;
} elsif ($UNIT_FLAG eq "S") {
$BTEQCMD = BTEQ_S4($dbh);
} elsif ($UNIT_FLAG eq "Z") {
$BTEQCMD = BTEQ_Z1($dbh);
} else {
print "&cedil;\n";
return 1;
}
ETL::disconnectETL($dbh);
return ETL::ExecuteBTEQ($BTEQCMD, $TX_DATE);
}
my $ret= main();
exit($ret);
</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_mt_0044.html">Teradata Syntax Migration</a></div>
</div>
</div>