Help with change in Data type

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
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Help with change in Data type

Post by sshettar »

Hi All,

I have this job where i am getting 32 fields at the output . these fields later has to mapped to a fields in a table most of whose data types do not match with these .
well the data types of all the fields in the output are of type Varchar and of different lengths.
well some these should be changed to decimal of length 8 and few to int of length 4 .
and few to dates of length 8
well how do i change the data type from varchar to decimal of length 8 and varchar to Int of length 4 and the same to date of length 8?

well i tried using PROMO_ID:decimal[8,0]= decimal_from_string(PROMO_ID)
for changing from varchar to decimal of length 8 .
am i correct and how do i do for int and date?



Please need help on this

Thanks in advance
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

Just make sure the input field is integer and map it to the output field. same goes for other data type conversions. You need not do any conversions if you are sure that the input data values correspond to the output data type
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Look under the functions listed in the Transformer stage on the right click menu. The subfolder of type conversions should help you out. You can always read the .pdf under your Start menu for more descriptions.
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
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Post by sshettar »

Well i need to convert the data type of the field from varchar to Int of lenght 8
and also from varchar to data type Date of length 8

what is the function i need to use for this in the modify stage?

Thanks
sshettar
Premium Member
Premium Member
Posts: 264
Joined: Thu Nov 30, 2006 10:37 am

Post by sshettar »

Well unfortuantely i cannot use the Parallel transformer as there is some problem with the parallael transformer here.
hence forth i cannot make use of those functions available in the transformer . i can only use basic transformer.

Any other way out to do this?

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

AsInteger() and StringToDate().
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

DSguru2B wrote:AsInteger() and StringToDate().
Why do we need to use this function if i am sure the data contains all integers and dates respectively?

I cant check it out as i dont have parallel installed with me. Can you please help me out on this?
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

In server it does not matter. In px it does. If you have any background in programming, especially c, you will know that characters are not the same as integers. They need typecasting to be changed from one form to another. Similarly with PX, as it is strongly typed like C, you need the conversions. Thats why these functions exist in the first place.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Krazykoolrohit
Charter Member
Charter Member
Posts: 560
Joined: Wed Jul 13, 2005 5:36 am
Location: Ohio

Post by Krazykoolrohit »

DSguru2B wrote:In server it does not matter. In px it does. If you have any background in programming, especially c, you will know that characters are not the same as integers. They need typecasting to be changed from one form to another. Similarly with PX, as it is strongly typed like C, you need the conversions. Thats why these functions exist in the first place.
Thanx.
Last edited by Krazykoolrohit on Thu Jan 18, 2007 2:38 pm, edited 1 time in total.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Because PX is strictly data typed. You must promote or demote accordingly. As for not have the Transformer, the only reason would be that your compiler is not configured. You can use the Modify stage, but you'll find that while a much faster stage, it is less "friendly" because of it's obvious manual typing effort.

The Transformer stage has made significant strides in flexibility and functionality. It's more legible and easier to understand and use. In the new few releases I'm confident engineering will get it to the point of matching the Modify in terms of performance. Unless you're counting microseconds and are concerned about significant accumulation of microseconds, consider the Transformer stage.

The "Rule of Thumb" to never use the Transformer stage in favor of Modify stage should be carefully reviewed on a case-by-case basis. The Modify stage cannot replace the Transformer stage all situations.
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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Slightly off topic, the decision about Transformer versus other stage types is also a function of version. Somewhere in version 7.1 Transformer stage performance was enhanced, and can now be preferred to Filter or Switch (for example) which are effectively interpreted rather than compiled. However, Modify stage is still best for the things that it can do - it's very primitive nature is the secret of its speed.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply