Page 1 of 1

Oracle Date field to Timestamp

Posted: Thu Mar 16, 2006 5:38 pm
by reddy
Hi Gurus,

I have both source and target tables as Oracle database.I am using custom sql in the source table to load into target.
I have a situation like this:

for postdate field source datatype is numeric but target datatype is timestamp
so in userdefined SQL i used
to_date(J1.JC_COST_DATE,'YYYYMMDD')

for currentfield is date datatype in source table but timestamp in target table

while running the datastage job i am getting following error:
Attempt to convert String value "15-MAR-06" to Timestamp type unsuccessful

Can you please light on me.

Thanks in advance.

Reddy

Posted: Thu Mar 16, 2006 6:13 pm
by lstsaur
Hi Reddy,
Oracle does not have a timestamp datatype. Therefore, timestamp fields intended for an Oracle target will need to be converted a to a date datatype.

Posted: Thu Mar 16, 2006 8:02 pm
by kris007
Try using TO_CHAR in place of to_date.

Kris

Posted: Thu Mar 16, 2006 9:06 pm
by rasi
Reddy

Your format is not correct that's the reason you are getting this error.
Attempt to convert String value "15-MAR-06" to Timestamp type unsuccessful
Use to_date(J1.JC_COST_DATE,'DD-MON-YY') that should work

Posted: Thu Mar 16, 2006 9:16 pm
by kcbland
All source data columns of data type DATE should use a TO_CHAR function with a mask of YYYY-MM-DD HH24:MI:SS. DS automatically puts this on the SQL for auto-generated SQL, but since you hand-wrote your SQL you must do this.

All target columns of data type DATE or TIMESTAMP should use a TO_DATE function with a mask appropriate to your NLS setting, usually YYYY-MM-DD HH24:MI:SS. Again, DS automatically puts this on the SQL for auto-generated SQL, but if you hand-wrote your DML you must do this.

Posted: Thu Mar 16, 2006 11:44 pm
by lstsaur
Hi Reddy,
Sorry, I misunderstood your problem. Try TO_CHAR(TO_DATE(J1.JC_COST_DATE, 'DD-MON-YY'), 'YYYY-MM-DD HH24:MI:SS') and make sure your target column's datatype is defined as VARCHAR2(32).
Please let me know the result.