Below teradata query is taking much more time and sitting in delay queue again n again? any prompt help is appreciated
/* FILE IMPORT BTEQ WITH PACK OPTION */
delete from appl.a;
.IF ERRORCODE <> 0 THEN .QUIT ERRORCODE;
.import FILE=KR.GSED200.LGSALES.txt;
.QUIET ON
.REPEAT * pack 1000
USING
DAY_NBR (CHAR(6))
,LOCN_NBR (CHAR(5))
,SLS_TYPE_CD (CHAR(1))
,DVSN_371_RETL_SLS_DLR (CHAR(12))
,DVSN_471_RETL_SLS_DLR (CHAR(12))
,DVSN_571_RETL_SLS_DLR (CHAR(12))
,DVSN_671_RETL_SLS_DLR (CHAR(9))
INSERT INTO app.a
(
DAY_NBR
,LOCN_NBR
,SLS_TYPE_CD
,DVSN_371_RETL_SLS_DLR
,DVSN_471_RETL_SLS_DLR
,DVSN_571_RETL_SLS_DLR
,DVSN_671_RETL_SLS_DLR
)
VALUES
(
:DAY_NBR
,:LOCN_NBR
,:SLS_TYPE_CD
,trim(:DVSN_371_RETL_SLS_DLR)
,trim(:DVSN_471_RETL_SLS_DLR)
,trim(:DVSN_571_RETL_SLS_DLR)
,trim(:DVSN_671_RETL_SLS_DLR)
);
.IF ERRORCODE <> 0 THEN .QUIT ERRORCODE;
.QUIET OFF
.LOGOFF
.QUIT
Related
using bteq script, I want to delete the temporary error and log tables created during TPT load namely ErrorTable1, ErrorTable2, LogTable.
I have prepared following bteq script with if-else, which will drop tables if it exists
.LOGON ${HOST}/${USER},${PASS};
SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.ErrorTable1';
.IF ACTIVITYCOUNT = 0 THEN GOTO CHECK_1;
DROP TABLE Test.ErrorTable1;
.LABEL CHECK_1;
SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.ErrorTable2';
.IF ACTIVITYCOUNT = 0 THEN GOTO CHECK_2;
DROP TABLE Test.ErrorTable2;
.LABEL CHECK_2;
SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.LogTable';
.IF ACTIVITYCOUNT = 0 THEN GOTO DONE;
DROP TABLE Test.LogTable;
.LABEL DONE;
.LOGOFF
.EXIT
My question is, in teradata bteq, can I use ACTIVITYCOUNT multiple times, like in above script, to check various table's existence?
I'm trying to import a csv in Teradata but I just get the message "query invalid" with no explanation. I tried changing the slashes to forward without any difference
create volatile table temp (
a varchar(255)
);
.IMPORT vartext ',' FILE = 'F:\xyz\abcdef.csv', skip = 1;
delete from temp;
.QUIET ON
.REPEAT *
USING (
a varchar(255)
)
INSERT INTO temp(a)
VALUES (
:a
);
.QUIT
.LOGOFF
i tried to import data into teradata through a bteq import data, but i can't because i have this problem:
* Failure 2621 Bad character in format or data of LT_CDG_UNICO.NRO_VUELO_
REF.
Statement# 1, Info =0
* Warning: Out of data.
This is i tried to import:
LA;100;null;null;2016-01-01;2050-01-01
I create this bteq for import this:
bteq << CARGA_CDG_UNICO > ${FILE_LOG} 2> ERROR_${FCH_HRA}.LOG
.LOGON ${SERVER}/${USER},${PASS};
.IMPORT VARTEXT ';' FILE='${FILE2}';
.REPEAT *
USING CDG_OPE(VARCHAR(20)), NRO_VLO(VARCHAR(20)), CDG_OPE_REF(VARCHAR(20)),NRO_VLO_REF(VARCHAR(20)), FCH_INI(VARCHAR(20)), FCH_FIN(VARCHAR(20))
INSERT INTO ${DBTB} (CDG_OPERADOR,NRO_VUELO,CDG_OPERADOR_REF,NRO_VUELO_REF,FCH_INI_VIGENCIA,FCH_FIN_ VIGENCIA) values (:CDG_OPE,:NRO_VLO,:CDG_OPE_REF,:NRO_VLO_REF,:FCH_INI,:FCH_FIN);
.IF ERRORCODE <> 0 THEN .QUIT ERRORCODE;
.LOGOFF;
.QUIT 0;
CARGA_CDG_UNICO
}
The null in your input file is treated as an actual value and your target is probably a numeric column, thus converting the string null fails.
You need to apply NULLIF, e.g.
NULLIF(CDG_OPERADOR_REF, 'null')
mload step
.LOGTABLE truser2.logtable;
.LOGON 127.0.0.1/truser2,trpass2;
.begin import mload tables coldata_test
WORKTABLES wt_test1
ERRORTABLES wt_test1 uv_test1
ERRLIMIT 1000
CHECKPOINT 100000
AMPCHECK NONE;
.layout test_layout;
.field col01 * varchar(255);
.field col02 * varchar(255);
.field col03 * varchar(255);
.DML LABEL test_insert
IGNORE MISSING UPDATE ROWS
DO INSERT FOR MISSING UPDATE ROWS;
UPDATE coldata_test SET col02 =:col02
,col03 = :col03
where col01 = :col01;
insert into coldata_test
values(
:col01,
:col02,
:col03);
.IMPORT INFILE /home/tdatuser/bin/data2.dat
LAYOUT test_layout FORMAT VARTEXT ','
APPLY test_insert;
.END MLOAD;
.LOGOFF;
data2.dat : abdfe,aasf,xxcvf
result : This MultiLoad import task cannot proceed: an unexpected
MultiLoad phase, data acquisition, was reported by the RDBMS.
what is problem??
I am trying to understand the equivalent of this statement
IF OBJECT_ID('Current') IS NOT NULL
DROP TABLE Current;
in Teradata.
Can someone help me out converting this statement to TD14. Thank you!
You can do this in at least newer versions of TD:
select
count (*)
from
dbc.tablesv where tablename = '<your table>'
and databasename = '<your db>'
having count (*) > 0;
.if activitycount = 1 then .GOTO DropTable;
.if activitycount <> 1 then .quit;
.LABEL DropTable
select 'DROP TABLE!';
drop table <your db>.<your table>;
Sadly enough, this won't work with volatile tables. If they are global temporary tables, you can use
select
count (*)
from
dbc.AllTempTablesVX where B_tablename =