Simple date from Seq file not uploading to Oracle

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
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Simple date from Seq file not uploading to Oracle

Post by dprasanth »

Hi,
I have a customer record in a PIPE delimited Customer File. The record format is as follows

750007|DET|514028073|514028073|01|75|1|M|Mr|M|David |Rewwick|D|Dear Mr Rewwick|Mr D Rewwick|rywyk|dyvyt|RewwickD|22-12-1
962|22|12|NULL|NULL|27 Fernwood Avenue|STREATHAM||London||SW16 1RD|SW161RD|27 Fernwood AvenueSW16 1RD|F65320000000000000
00|52 |NULL|NULL|NULL|NULL|N|Y|N|NULL|NULL|N|NULL|A|N|N|N|N|N|N|NULL|1RD|SW16|30-05-1995|125|NULL|NULL|NULL|NULL|08-06-
2002|System|125|09-03-2002|System|125| |N|END

I am using a sequential Input stage and OCI Oracle stage. None of the date fields are getting uploaded to the database. From what I see, the file looks fine. I tried uploading all the fields expect the date field and it worked. I tried each and every type of date conversion in the transformer stage and each one is throwing the same error
RNK_SEQOCI_V4_cussm..Transformer_29: ORA-01861: literal does not match format string Really puzzled about this situation. All the date fields have been declared as TIMESTAMP on oracle. So I even tried converting the date field to timestamp and still it is throwing me the same error. Has anyone of you encountered this sitation?The input columns and output date columns have the same data type and other attributes.

Any Help is welcome.Thanks
Dprasanth
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Look at the generated SQL in the Oracle stage. Note the format it expects the DATE fields declared as Timestamps to come in as. Transform your fields to match that format. Problem goes away. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

The ORAOCI stage adds a To_DATE() to all columns where the datatype is DATE when using generated SQL. You need to make sure your datatypes say DATE and get all your dates into YYYY-MM-DD HH24:MI:SS format, or atleast YYYY-MM-DD in order to take advantage of generated SQL.

If you wrote user-sql, it's up to you to put the TO_DATE() on all your date columns. This is a long documented requirement for using the ORAOCI stages.
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
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Post by dprasanth »

kcbland wrote:The ORAOCI stage adds a To_DATE() to all columns where the datatype is DATE when using generated SQL. You need to make sure your datatypes say DATE and get all your dates into YYYY-MM-DD HH24:MI:SS format, or atleast YYYY-MM-DD in order to take advantage of generated SQL.

If you wrote user-sql, it's up to you to put the TO_DATE() on all your date columns. This is a long documented requirement for using the ORAOCI stages.
I had changed all the date to YYYY-MM-DD using OCONV. But still I am facing the same problem. I did see in the generated sql that all the dates are getting converted to YYYY-MM-DD HH24:MI:SS. So I did change the date format. But still no use :-(
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Post by dprasanth »

chulett wrote:Look at the generated SQL in the Oracle stage. Note the format it expects the DATE fields declared as Timestamps to come in as. Transform your fields to match that format. Problem goes away. :wink:
My input date fields just have a date in them, they don't have timestamp. I tried changing the date to timestamp. But still I am facing the same problem. I used various functions like DategenerictoOCIwithtimestamp etc. But still no results
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Simple - concatenate a zero time onto the end of your date:

Code: Select all

YourField : " 00:00:00"
-craig

"You can never have too many knives" -- Logan Nine Fingers
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Post by dprasanth »

chulett wrote:Simple - concatenate a zero time onto the end of your date:

Code: Select all

YourField : " 00:00:00"
I Tried concatenating zero to the date field. I tried even converting String to Date format. I don't know why it is still giving me the same error :-(
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Post by dprasanth »

chulett wrote:Simple - concatenate a zero time onto the end of your date:

Code: Select all

YourField : " 00:00:00"
I was just searching for a function to convert String to Date. But couldn't find it. Are there any functions that will convert string to date?
dprasanth
Charter Member
Charter Member
Posts: 90
Joined: Fri Oct 07, 2005 7:55 am

Post by dprasanth »

dprasanth wrote:
chulett wrote:Simple - concatenate a zero time onto the end of your date:

Code: Select all

YourField : " 00:00:00"
I was just searching for a function to convert String to Date. But couldn't find it. Are there any functions that will convert string to date?
I have cracked the problem. The date fields are declared as DATE in the database. But for some reason when they are imported to the table definition they are getting changed to TIMESTAMP. So what I did was changed the TIMESTAMP to date and it worked. Thanks a lot for everyone who helped. But really couldn't figure out how the datatype changed while importing :?:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

dprasanth wrote:But really couldn't figure out how the datatype changed while importing :?:
That's because a DATE field in Oracle is really a Timestamp in disguise and always carries a time portion. When it looks like it doesn't, that's because the time portion has been set to zeroes as we've discussed earlier in the thread. But there is always one there.

I prefer to always treat Oracle dates as Timestamps, again as part of the standardization we've also discussed. If you always treat them as Timestamps with explicit control over what goes into the time portion (including zeroes when needed) enforced by standard routines leveraged by all developers - then you will never have a problem with Oracle date fields. :wink:

This is much akin to what Ken said in other of your posts.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply