Timestamp issue inserting into Oracle table

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

sidharthasaha
Participant
Posts: 9
Joined: Tue May 31, 2005 3:44 pm

Timestamp issue inserting into Oracle table

Post by sidharthasaha »

I have a timestamp value in a flat file which I need to insert into oracle table. The I/P value looks like '2007-10-31 00:00:00.000'. In thae transformer I'm using the following function to insert the value.

StringToTimestamp(In_Trns_t1clod.ORIGINAL_OFF_START_DATE , "%yyyy-%mm-%dd %hh:%nn:%ss")

I've also tried with "%yyyy-%mm-%dd %hh:%nn:%ss.3" as the format

I'm getting a warning 'When checking operator: When validating export schema: At field "ORIGINAL_OFF_START_DATE": "null_field" length (19) must match field's fixed width (21)'.

If I check the Oracle Log file in unix I'm seeing the following error message

Record 1: Rejected - Error on table FACTDATA.T1CLOD1, column ORIGINAL_OFF_START_DATE.
ORA-01861: literal does not match format string

The timestamp field format looks like in the same log file

ORIGINAL_OFF_START_DATE 9:27 19 DATE YYYY/MM/DD HH24:MI:SS
NULL if ORIGINAL_OFF_START_DATE = BLANKS

Please Help.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

On the columns tab, select microseconds for timestamp column by edit cell option and try to insert records.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You maintain it as varchar/char in Datastage till you load it. While loading it, convert it into Date (not timestamp) using TO_DATE function in the query.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That depends on if the target Oracle column is a DATE or if it is indeed one of the TIMESTAMP flavors.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sidharthasaha
Participant
Posts: 9
Joined: Tue May 31, 2005 3:44 pm

Post by sidharthasaha »

The target column is timestamp. So I need to insert the time information along with the date. How do I use TO_DATE function while inserting. I'm using Oracle Eterprise Stage with LOAD option.
sidharthasaha
Participant
Posts: 9
Joined: Tue May 31, 2005 3:44 pm

Post by sidharthasaha »

Can somebody please help on this issue. We are not able to move forward with the development without resolving this problem.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Isn't your support provider providing support, which you are paying them to do?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
krisna
Participant
Posts: 77
Joined: Tue Apr 08, 2008 11:33 pm

date & time in transformer

Post by krisna »

sidharthasaha wrote:Can somebody please help on this issue. We are not able to move forward with the development without resolving this problem.
You can try this format in transformer for the columns

Oconv(Iconv(Trim(<linkname.fieldname>),"D/DMY[2,2,2]"),"D4-YMD"): " " : Oconv(Time(), "MTS")
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

Oconv() and Iconv() functions are not available in parallel Transformer stages.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jinm
Premium Member
Premium Member
Posts: 47
Joined: Tue Feb 24, 2004 1:59 am

Post by jinm »

source field [1,19]
But then you need to be sure your source data corresponds with the mask you provided.
Works fine for us, also when tranporting timestamps from say SQL Server to Oracle
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Re: Timestamp issue inserting into Oracle table

Post by swapnilverma »

sidharthasaha wrote:I have a timestamp value in a flat file which I need to insert into oracle table. The I/P value looks like '2007-10-31 00:00:00.000'. In thae transformer I'm using the following function to insert the value.

StringToTimestamp(In_Trns_t1clod.ORIGINAL_OFF_START_DATE , "%yyyy-%mm-%dd %hh:%nn:%ss")

I've also tried with "%yyyy-%mm-%dd %hh:%nn:%ss.3" as the format

I'm getting a warning 'When checking operator: When validating export schema: At field "ORIGINAL_OFF_START_DATE": "null_field" length (19) must match field's fixed width (21)'.

If I check the Oracle Log file in unix I'm seeing the following error message

Record 1: Rejected - Error on table FACTDATA.T1CLOD1, column ORIGINAL_OFF_START_DATE.
ORA-01861: literal does not match format string

The timestamp field format looks like in the same log file

ORIGINAL_OFF_START_DATE 9:27 19 DATE YYYY/MM/DD HH24:MI:SS
NULL if ORIGINAL_OFF_START_DATE = BLANKS

Please Help.






As far as I understand you are converting string[21] to Timestamp[19]....

Try doing StringToTimestamp(trim(In_Trns_t1clod.ORIGINAL_OFF_START_DATE , "%yyyy-%mm-%dd %hh:%nn:%ss")


Hope this helps .... if not :shock: then provide some sample records
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
DSDexter
Participant
Posts: 94
Joined: Wed Jul 11, 2007 9:36 pm
Location: Pune,India

Post by DSDexter »

Please post some sample records, So that everyone will understand where the problem lies. Also describe the job description, what the job is doing and In which stage are you getting the Null field length warning?
Thanks
DSDexter
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Try using To_timestamp function in Database stage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sidharthasaha
Participant
Posts: 9
Joined: Tue May 31, 2005 3:44 pm

Post by sidharthasaha »

The input value is ''2007-10-31 00:00:00.000". I'm reading this in Char [23] . The job layout looks like

sequential file -> transformer -> Oracle Enterprise(with load option)

All the warnings and errors are in the oracle enterprise stage. All the fields are nullable but there are not any null values in the input. I even tried to hard code the date in the StringToTimestamp transformation. That also is not helping.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

Use the derivation :

Code: Select all

StringToTimestamp(substr(left(In_Trns_t1clod.ORIGINAL_OFF_START_DATE,19) , "%yyyy-%mm-%dd %hh:%nn:%ss")
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
Post Reply