Hi Gurus,
Now I am able to login properly in both Batch as well as Interactive mode through BTEQ.
The problem which I am facing is with IMPORT of data to Database.
Details of the IMPORT.
.IMPORT vartext '|' FILE=/home/dsadm/Automation/fact_data_run1.txt;
.REPEAT *
USING
REPORT_NAME (VARCHAR(50)),
SUB_REPORT_NAME (VARCHAR(100)),
OPTIONAL_FLAG (VARCHAR(1)),
DATA_DATE (VARCHAR(20)) ,
PROCESS_DATE (VARCHAR(20)) ,
Load_START (VARCHAR(20)) ,
Load_END (TIMESTAMP(0)) ,
IS_WEEKLY (VARCHAR(20)) ,
IS_MONTHLY (VARCHAR(20)),
FAILURE (VARCHAR(20)),
FAILURE_SR (VARCHAR(20)),
FAILURE_REASON (VARCHAR(1000)),
RAG_STATUS (VARCHAR(20)),
HAD_DELAY (VARCHAR(20)),
DELAY_REASON (VARCHAR(20)),
UPDATED_BY (VARCHAR(20))
INSERT INTO NDW_ETL_WORK.NDW_REPORT_FACT (REPORT_NAME, SUB_REPORT_NAME,OPTIONAL_FLAG,DATA_DATE,PROCESS_DATE,Load_START,Load_END,IS_WEEKLY,IS_MONTHLY,FAILURE,
FAILURE_SR,FAILURE_REASON,RAG_STATUS,HAD_DELAY,DELAY_REASON,UPDATED_BY)
values
(
:REPORT_NAME,
:SUB_REPORT_NAME,
:OPTIONAL_FLAG,
CAST(:DATA_DATE AS DATE),
CAST(:PROCESS_DATE AS DATE),
CAST(:Load_START AS TIME(0)),
CAST(:Load_END AS TIME(0)),
:IS_WEEKLY,
:IS_MONTHLY,
:FAILURE,
:FAILURE_SR,
:FAILURE_REASON,
:RAG_STATUS,
:HAD_DELAY,
:DELAY_REASON,
:UPDATED_BY
);
Sample Record: [ There is end of line in the source file, i.e. cursor will point to begining of next line]
SUBSCRIBER_REPORT|SUBSCRIBER_REPORT|N|2013-03-12|2013-03-13|12:30:00 AM|04:35:00 AM|N|N|N|N|N|GREEN|N|N|SYSTEM
Table Def :
CREATE SET TABLE NDW_ETL_WORK.NDW_REPORT_FACT ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
REPORT_NAME VARCHAR(50) CHARACTER SET LATIN NOT CASESPECIFIC,
SUB_REPORT_NAME VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC,
OPTIONAL_FLAG CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC CHECK ( OPTIONAL_FLAG IN ('Y','N') ),
DATA_DATE DATE FORMAT 'YYYY-MM-DD' NOT NULL ,
PROCESS_DATE DATE FORMAT 'YYYY-MM-DD' NOT NULL,
Load_START TIMESTAMP(0),
Load_END TIMESTAMP(0),
IS_WEEKLY CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC CHECK ( IS_WEEKLY IN ('Y','N') ),
IS_MONTHLY CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC CHECK ( IS_MONTHLY IN ('Y','N') ),
FAILURE CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC CHECK ( FAILURE IN ('Y','N') ),
FAILURE_SR VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC,
FAILURE_REASON VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC,
RAG_STATUS VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC,
HAD_DELAY CHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC CHECK ( HAD_DELAY IN ('Y','N') ),
DELAY_REASON VARCHAR(1000) CHARACTER SET LATIN NOT CASESPECIFIC,
UPDATED_BY VARCHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL)
UNIQUE PRIMARY INDEX NDW_REPORT_FACT_UPI ( REPORT_NAME ,SUB_REPORT_NAME ,
DATA_DATE );
Now while executing, the BTEQ I am receiving the following error:
*** Failure 2673 The source parcel length does not match data that was defined.
Statement# 1, Info =1
*** Failure 2673 The source parcel length does not match data that was defined.
Statement# 1, Info =1
*** Warning: Out of data.
All the data sets are moving as rejected record.
Can you please suggest me on this. As now I am really stuck.
:(
Hi Sudipta,
the error is obvious, you define Load_END as a TIMESTAMP instead of VARCHAR :-)
You should also add a FORMAT to the cast to TIME due to AM/PM:
CAST(:Load_END AS TIME(0) FORMAT 'hh:mi:ssBt'),
And you should add a PACK (if there are no errors in your input data) to get a faster load.
Dieter
Hi Dieter,
I am really puzzled with Timestamp handling.
I have re-arranged my data as :
SUBSCRIBER_REPORT|SUBSCRIBER_REPORT|N|2013-03-12|2013-03-13|2013-03-13 12:30:00|2013-03-13 04:35:00|N|N|N|N|N|GREEN|N|N|SYSTEM
In USING part of IMPORT i have made the ammendments as VARCHAR as suggested:
Load_START (VARCHAR(20)) ,
Load_END (VARCHAR(20)) ,
In the INSERT query i have used the following:
CAST(:Load_START AS TIME(0)FORMAT 'yyyy-mm-dd hh:mi:ss'),
CAST(:Load_END AS TIME(0)FORMAT 'yyyy-mm-dd hh:mi:ss'),
And now the PARCEL LENGHT error is fixed but receiving invalid time error:
*** Warning: Out of data.
*** Failure 3530 Invalid FORMAT string 'yyyy-mm-ddhh:mi:ss'.
Statement# 1, Info =0
Can you please suggest on this.
Also if you have any posts/articles for Date Time arithmetic in Teradata, it will be really helpfull for me.
Hi Sudipta,
there are different datatypes in Teradata for DATE, TIME and TIMESTAMP.
When you cast a string to a time you can't use a date part, when you cast to a date you can't use a time part.
In your case either keep data as is and use the cast i showed or use the rearranged data and cast to a timestamp.
And because the FORMAT is based on Cobol you must use a 'B' instead of a blank in the format string: yyyy-mm-ddBhh:mi:ss
You'll find a lot about working with DateTime datatypes scattered throughout the manuals and there's an old article written by Geoffrey Rommel on the TeradataForum website covering the basics: http://www.teradataforum.com/l081007a.htm
It's a bit outdatet, as there are more advanced datatypes/functions, but there are two good articles on PERIODs by Rob Garrison:
http://developer.teradata.com/database/articles/exploring-teradata-13s-period-functions
Dieter
hi guys,
im the below export script to export data,
.quit
and using the below script to import it,
.quit
im gettin the error,
the source parcel lenght does not match the data that was defined.
can anyone help me here????
Hi Manjunath.M,
when you TRIM a CHAR(2) i changes to a VARCHAR(2).
You can either
Dieter,
Thanks a lot , this worked :)
Hi All,
I am new to teradata. I am importing data from text file into table.
Text file data:
1,a,3
Hi Malli,
when you define VARTEXT all fields in USING must be VARCHARs:
using
dno (VARCHAR(11)),
dname(VARCHAR(200)),
eno(VARCHAR(11))
HI Dieter,
Thanks you so much its worked.
One more doubt: i am exporting data in all modes.But incase of .EXPORT DIF mode i am unable to get column names in the result set.
Please help me on this
Thanks in advance,
Malli