Teradata Multi load Not Proceed - teradata

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

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

I can't insert null variable through bteq import data

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

"Invalid cursor state" error with odbc load command

What does this cryptic error mean?
> odbc load, exec("
> CREATE VOLATILE MULTISET TABLE vol_tab AS (
> SELECT TOP 10 user_id FROM dw_users
> )
> WITH DATA
> PRIMARY INDEX(user_id)
> ON COMMIT PRESERVE ROWS;
> ") clear dsn("mozart");
The ODBC driver reported the following diagnostics
[Teradata][ODBC Teradata Driver] Invalid cursor state.
SQLSTATE=24000
r(693);
You are getting this error because you are telling Stata to load something, but your code does not have a SELECT clause that is not part of the table creation. If you add a SELECT clause at the bottom, it will work.
Alternatively, you can use odbc exec("SqlStmt") syntax if you just want to create a table.
Here's an example:
/* Works */
odbc load, exec("
CREATE VOLATILE MULTISET TABLE vol_tab AS (
SELECT TOP 10 user_id FROM dw_users
)
WITH DATA
PRIMARY INDEX(user_id)
ON COMMIT PRESERVE ROWS;
SELECT * FROM vol_tab;
") clear dsn("mozart") lowercase multistatement;
format user_id %20.0fc;
sort user_id;
list, clean noobs;
/*Also Works */
odbc exec("
CREATE VOLATILE MULTISET TABLE vol_tab AS (
SELECT TOP 10 user_id FROM dw_users
)
WITH DATA
PRIMARY INDEX(user_id)
ON COMMIT PRESERVE ROWS;
"), dsn("mozart");
/* Fails: Load With No Bottom Select Clause */
odbc load, exec("
CREATE VOLATILE MULTISET TABLE vol_tab AS (
SELECT TOP 10 user_id FROM dw_users
)
WITH DATA
PRIMARY INDEX(user_id)
ON COMMIT PRESERVE ROWS;
") clear dsn("mozart");

How can drop table if table exists in oracle?

I am trying to create database by my java application using my generated schema file. In schema I have included drop query also. But I want to do some improvements for DROP QUERY. So I want to check the existence of db objects before running drop query and drop only when if it exists.
I googled for it and found some oracle link, Some link suggest following syntax and some mentioned that ORACLE does not support such syntax.
SYNTAX A:
IF EXISTS DROP TABLE TABLE_NAME
SYNTAX B:
DROP [TEMPORARY] TABLE [IF EXISTS]
tbl_name [, tbl_name] ...
[RESTRICT | CASCADE]
I also tried following queries:-
IF EXISTS (SELECT * FROM dba_objects WHERE OBJECT_NAME = 'BBB' )
DROP TABLE [BBB]
but it was giving error:-
Error starting at line 2 in command:
DROP TABLE [BBB]
Go
Error report:
SQL Error: ORA-00903: invalid table name
00903. 00000 - "invalid table name"
*Cause:
*Action:
Error starting at line 1 in command:
IF EXISTS (SELECT * FROM dba_objects WHERE OBJECT_NAME = 'BBB' ) DROP TABLE [BBB]
Error report:
Unknown Command
I refered following links:-
https://community.oracle.com/thread/2421779?tstart=0
Please suggest me if there any other queries to drop table with condition if table exists.
Drop table with no check. If any error exists you'll never know when something went wrong.
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE my_table';
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
Or you can search in Oracle dictionary.
DECLARE
l_cnt NUMBER;
BEGIN
SELECT count(*)
INTO l_cnt
FROM user_tables
WHERE table_name = 'MY_TABLE';
IF l_cnt = 1 THEN
EXECUTE IMMEDIATE 'DROP TABLE my_table';
END IF;
END;
If you run following code you do not have to check if table exists and in case of errors (table is locked with now wait or any other you will know about it)
begin
for c1 in (select owner,table_name from dba_tables where table_name='MY_TABLE') loop
execute immediate 'drop table '||c1.owner||'.'||c1.table_name||'';
end loop;
end;
Try this : It will drop table 'table_name' if it is present .
declare
a varchar2(700) ;
begin
execute immediate ' SELECT CASE WHEN tab = 1
THEN ''DROP TABLE TABLE_NAME''
ELSE ''select 1 from dual''
END
FROM ( SELECT sum(case when table_name = ''TABLE_NAME'' then 1 else 0 end ) as tab FROM user_tables)' into a;
EXECUTE IMMEDIATE a;
end;

Resources