Date conversion

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ds_team
Participant
Posts: 48
Joined: Sun Dec 03, 2006 12:18 am

Date conversion

Post by ds_team »

I have date comming in flat file. My target is Teradata.In terada the type of the date is timestamp. How to convert the date comming in flat file to timestamp type in the transformer stage.
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

What is the format of the incoming date field? What is the format of a Teradata timestamp? You need provide that information in order to proceed further.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
ds_team
Participant
Posts: 48
Joined: Sun Dec 03, 2006 12:18 am

Error while loading date to TERADATA table

Post by ds_team »

in the sequential file stage we have kept the type unknown for the incomming date. In teradata table the type is Timestamp with length 22.
We are getting below error .

Teradata_Enterprise_1,0: At field "Effective_Date": Default value not valid for type "timestamp"; text: default="0001-01-01 00:00:00.00"

At field "Expiration_Date": Default value not valid for type "timestamp"; text: default="0001-01-01 00:00:00.00"

We have kept the type as time stamp in transformer stage for target teradata table.
Conversion function used in transformer is
StringToTimestamp(DSLink4.Effective_Date,"%dd/%mm/%yyyy %hh:%nn:%ss")

In sequential file date is comming as
27/12/2004 0:00:00
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

PX formats have to match exactly; in your case the time part in the string is "0:00:00" which I think is causing the problem.
ds_team
Participant
Posts: 48
Joined: Sun Dec 03, 2006 12:18 am

Post by ds_team »

But in the sequential file stage the type for this field is kept as unknown. How can i solve this problem. The date in the file need to be loaded to TERADATA table. Please give me some ideas :(
umamahes
Premium Member
Premium Member
Posts: 110
Joined: Tue Jul 04, 2006 9:08 pm

Hi

Post by umamahes »

First validate the timestamp field with IsValid("TimeStamp", StringToTimeStamp(DSLink4.TimeStamp,"%dd/%mm/%yyyy %hh:%nn:%ss") )

After that if it is valid time stamp then convert that into time stamp format else put the default time stamp according to your project standard(for ex 9999-12-31 00:00:00)

If StageVar1 then StringToTimestamp(DSLink4.TimeStamp,"%dd/%mm/%yyyy %hh:%nn:%ss") else DSJobStartTimestamp
HI
ds_team
Participant
Posts: 48
Joined: Sun Dec 03, 2006 12:18 am

Re: Hi

Post by ds_team »

Can you please explain it bit more clearly. I am not getting your explanation :( ..

So Sorry for the trouble
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Unknown is the sql type. It can also be varchar, it can also be char. The point that ArndW and umamahes are trying to make is that you need to first check for a valid format. If you find a valid format then change it to timestamp, else you can do something with it. You can possible flag it, reject it etc. etc. etc.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Look at Appendix A in the Parallel Job Developer's Guide for the data type conversion functions that are available in the Transformer stage. Surely some combination of these will address your question.

You could, as an alternative, use a Modify stage to effect the data type translation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply