Oracle Date field to Timestamp

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Oracle Date field to Timestamp

Post 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
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post 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.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Try using TO_CHAR in place of to_date.

Kris
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post 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
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post 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.
Post Reply