Timestamp 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
reachmexyz
Premium Member
Premium Member
Posts: 296
Joined: Sun Nov 16, 2008 7:41 pm

Timestamp Conversion

Post by reachmexyz »

Hello All

I am reading a field name POLICY_EFF_DT from oracle table using OCI Stage and output is fed to dataset.
POLICY_EFF_DT datatype is Date .
When i try to read the field direclty i got an error like
"No datatype conversion form timestamp to date"
Then i modified the quer like
To_date(policy_eff_dt, 'YYYY:MM:DD HH24:MI:SS').
When i run the job, i got the below error.
The modify operator has a binding for the non-existent output field "POLICY_EFF_DT".

Same query executes successfully in Oracle.
Do i need to any transformations for date field in Parallel edition.

In oracle it looks only Date datatype exists eventhough it has timestamp value.
How can i read this field in OCI stage in parallel.
In OCI Date only takes "YYYY:MM:DD" format.
Do i need to convert date to char and read the field
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You use TO_CHAR() when selecting, not TO_DATE() as it already is one in Oracle as thus only used when loading data into a DATE field. Then the appropriate StringTo?? function can convert it to whatever you need, date or timestamp, inside the job depending if you need the time portion or not.

And lose the colons in the date mask, dashes would be more appropriate there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Use "To_date(policy_eff_dt, 'YYYY:MM:DD HH24:MI:SS') POLICY_EFF_DT " in your query.
tsamui
Participant
Posts: 23
Joined: Fri May 04, 2007 3:05 am
Location: Kolkata

Post by tsamui »

Change the POLICY_EFF_DT data type to Timestamp. I think OCI stage will able to read the date properly.

Actually if you import the metadata of the table by 'Import Table Definition' functionality, the data type of the column will be Timestamp.
Thanks&Regards
-------------------
Tsamui
lohit43
Participant
Posts: 1
Joined: Wed May 20, 2009 9:23 am

Post by lohit43 »

Use "To_date(policy_eff_dt, 'YYYY:MM:DD HH24:MI:SS') as POLICY_EFF_DT " in query.
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

try using, to_char(<column_name>, 'yyyy-mm-dd hh24:mi:ss') and make the data type as varchar 19 or 26.
Thanks
Karthick
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

the vital response...
tsamui wrote:Change the POLICY_EFF_DT data type to Timestamp. I think OCI stage will able to read the date properly.

Actually if you import the metadata of the table by 'Import Table Definition' functionality, the data type of the column will be Timestamp.
An Oracle date still holds the time field and is therefore actually a timestamp.

If you want just the date, do a
to_char(<field>, 'YYYY-MM-DD') policy_blah_blah

i.e. leave out the time part as DataStage will expect a timestamp datatype if time is specified.
Gladiator1
Participant
Posts: 3
Joined: Tue May 05, 2009 11:57 pm

Post by Gladiator1 »

I have the same problem,in Oracle the EFF_DT field has a DATE datatype.When i try to use in an Oracle Enterprise stage and supplying the below query

SELECT to_char(PIP.EFF_DT,'YYYY-MM-DD') as START_DT
FROM table

it is giving the error

Error when checking operator: When binding output interface field "START_DT" to field "START_DT": No default type conversion from type "ustring[max=75]" to type "date".

Help me!!
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

SELECT to_char(PIP.EFF_DT,'YYYY-MM-DD') as START_DT
FROM table
First try to go through the error message where it says the columns' datatype is Date and by using to_char() you are passing string to it.

Use to_date() or change the field type as varchar.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
Gladiator1
Participant
Posts: 3
Joined: Tue May 05, 2009 11:57 pm

Post by Gladiator1 »

Thanks Priya..

I found a solution by getting the EFF_DT accepted as timestamp field and later on in the job i typecasted using TimestamptoDate funtion in the transfromer before inserting it into the target table.
Post Reply