Format 195,231 (char) to 195231 (Numeric)

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

Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Craig, It worked out!! :roll:

Thanks!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pnchowdary wrote:Can't we use the Real function in this scenario?
Not sure as I haven't had a need to use that one before. Might be something to try for grins.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Titto wrote:It worked out!!
Yah! :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

chulett wrote:Still think math would do the trick...

Code: Select all

If Len(Trim((MYLINK.COST)) = 0 Then 0 Else MYLINK.COST * 1
Give that a shot. :wink:
Craig, still have the problem :cry: .. In my input data comes like 234- (negative) values, above tric is not working out!! and if i don't trim(MYLINK.COST,',','A')*1 then it is not transforming values greater than thousands like 195,195. But the problem is with negative numbers, how do i handle them.
Thanks in advance!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is the datatype/sizes of both fields in your job? What exactly happens to negative numbers?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Code: Select all

Source Date(CHAR(15))     Target Data (DECIMAL (15,2))
          123,123                           123123.00  (tric works)
          123                                  123.00       (tric works)
          231- (negative)                 0.00      (tric doesn't work but it suppose to be 231.00-


Right now with the tric all negative numbers are tranformed to 0.00.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You need to take the rightmost char to check whether it is a sign. Try using what you have learnt earlier.
ysureshv
Participant
Posts: 2
Joined: Fri Jul 15, 2005 12:16 pm

Post by ysureshv »

pnchowdary wrote:Hi Craig,

That was a nice little trick :idea: . Can't we use the Real function in this scenario?
If you are sure you have only ' , ' in your column , you can ereplace that with null and check for Num of that field and insert in the Num field.

Trim(Ereplace(yourcolumn,',',''))
and check this result is a Num or not.

Suresh
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

Sainath.Srinivasan wrote:You need to take the rightmost char to check whether it is a sign. Try using what you have learnt earlier.
i used following transformation!

Code: Select all

IF Len(Trim(MYLINK.COST)) = 0 
   Then 0 
Else 
   IF Right(Trim(MYLINK.COST,',','A'),1) = '-' 
   Then '-':(Trim(Trim(MYLINK.COST,',','A'),'-','A'))
Else Trim(MYLINK.COST,',','A')*1
it is working fine, is there any other easy way to achieve this..

Thanks
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Titto,

I believe that, it is as easy as it gets, to meet your requirement.
Thanks,
Naveen
Post Reply