I can't insert null variable through bteq import data - unix

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')

Related

Teradata Error 2679 when loading text file into table using MLoad

I have a problem with loading my data into teradata table using MLoad. I have a text file with a data which is an output from SQL query.
851|73214|2019-01-03|2019-01-03|98.081270|RFF|249872083.40
854|73215|2019-01-03|2019-01-03|98.081270|RFF|355015298.0400
881|96634|2017-05-22|2017-05-22|97.697560|RFF|-6961747.270
and I'm trying to load this data using this mld file:
.LOGTABLE dss.load_DEALS7_log;
.RUN FILE "C:\PASS.TXT";
RELEASE MLOAD dss.DEALS;
drop table dss.DEALS;
create multiset table dss.DEALS
(
FILE_ROWNUM INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 MINVALUE -2147483647 MAXVALUE 100000000 NO CYCLE),
DEAL INTEGER,
EFFECT_DATE VARCHAR(80),
MAT_DATE VARCHAR(80),
CON DECIMAL(28,12),
C_CODE VARCHAR(80),
QUALITY DECIMAL(19,4),
LOAD_DTE DATE FORMAT 'YYYY-MM-DD'
)primary index(FILE_ROWNUM);
.BEGIN MLOAD TABLES dss.DEALS SESSIONS 2;
.LAYOUT FILE;
.FIELD DEAL * VARCHAR(80);
.FIELD EFFECT_DATE * VARCHAR(80);
.FIELD MAT_DATE * VARCHAR(80);
.FIELD CON * VARCHAR(80);
.FIELD C_CODE * VARCHAR(80);
.FIELD QUALITY * VARCHAR(80);
.DML LABEL LOAD;
INSERT INTO dss.DEALS VALUES
('',
:DEAL,
:EFFECT_DATE,
:MAT_DATE,
:CON,
:C_CODE,
:QUALITY,
CURRENT_DATE
);
.IMPORT
INFILE "C:\deals.txt"
LAYOUT FILE
format VARTEXT '|' DISPLAY ERRORS NOSTOP
APPLY LOAD
;
.END MLOAD;
.LOGOFF;
The problem is that the final table is empty and every row is in dss.ET_DEALS table with ErrorCode 2679. I know that the ErrorField is QUALITY, but I don't know why It won't load. The data seems alright. Teradata docs say - "This error occurs when the user submits a numeric-to-character conversion with an illegal format, or when, in converting characters to numeric, either the data or the format contains a bad character." At first I thought That It's because of negative numbers, but then there should only be few rows and not whole input data in ET table. Any help would be greatly appreciated!
I deleted and crated the tables from ground up and also added
.FILLER * VARCHAR(80);
in my mld file and It works fine.

Teradata - query invalid when importing file

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

OperationalError: near "(": syntax error" at SQLite3

After taking a crash course for SQLite3, I tried to make a db for my first project:
import sqlite3 as db
conn = db.connect('todo.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE todo(id serial primary key, title text, created
timestamp default now(), done boolean default 'f')")
cursor.execute("INSERT INTO todo (title) VALUES('Learn web.py')")
Unfortunately I receive this error:
OperationalError: near "(": syntax error" at SQLite3
I do not understand what's wrong with the code. Can anyone explain what I am doing wrong?
As shown in the documentation, if the default value is not a simple value, it must be enclosed in parentheses:
CREATE TABLE todo(
...,
created timestamp default (now()),
done boolean default 'f'
);
(And 'f' is not a valid value for a boolean. And now() is not an SQLite function.)

Teradata Multi load Not Proceed

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??

Convert NULL to Blank TPT Fast Load

Insert into emp values
(:FNAME ,.......
Above Sample Code from TPT works fine.
I want to convert null values in flatfile to blank while loading
insert into emp values ( COALESCE(:Fname,' '),.... -- Throws ERROR
TPT_INFRA: TPT04046: Error: Line 193 of Job Script File 'tpscript4.txt': Adjacen
t quoted strings must be separated by the
concatenation operator: '||'.
Job script preprocessing failed.
insert into emp Values ( case when :Fname is null then ' ' else :Fname End,... --Throws Error
Teradata Parallel Transporter Version 13.10.00.02
TPT_INFRA: TPT04046: Error: Line 191 of Job Script File 'tpscript4.txt': Adjacen
t quoted strings must be separated by the
concatenation operator: '||'.
Job script preprocessing failed.
Job terminated with status 8.
When used Case when in Select oerator for fastload:
TO OPERATOR (UPDATE_OPERATOR[2])
SELECT case when FNAME is null then ' ' else FNAME,LNAME,....
FROM OPERATOR (FILE_READER[2]);
ERROR:
TPT_INFRA: Syntax error at or near line 249 of Job Script File 'tpscript4.txt':
TPT_INFRA: At "SELECT" missing SEMICOL_ in Rule: Job Definition Body
Compilation failed due to errors. Execution Plan was not generated.
Job script compilation failed.
Job terminated with status 8.
Note: with out the case in select it is working fine ,
APPLY('insert into emp values ( COALESCE(:Fname,'' ''),....') Worked with Mload
and
SELECT CASE WHEN Fname IS NULL THEN ' ' ELSE Fname END AS Fname,... FROM OPERATOR worked with Fload
You didn't specify which error is returned, i assume it's related to the single quotes. Your INSERT is probably within an APPLY('INSERT ....;') you might try two single quotes to get one quote in a string:
APPLY('insert into emp values ( COALESCE(:Fname,'' ''),....')
Or do it in the SELECT (COALESCE is not supported here):
SELECT
CASE WHEN Fname IS NULL THEN ' ' ELSE Fname END AS Fname,
...
FROM OPERATOR

Resources