Decimal/String manipulation problem

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
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Decimal/String manipulation problem

Post by abc123 »

TempVal: StripWhiteSpace(Link1.IncomingCol) * 100

Data type of IncomingCol is char.

If I do:
Left(TempVal, index(TempVal,'.',1)-1)

it gives me the error:

Numeric string expected for returned value from function call 'strip_whitespace'. Use default value.

However, if I do:

Left(Left(TempVal, index(TempVal,'.',1)), Len( Left(TempVal, index(TempVal,'.',1) ))-1)

it works eventhough I think it is a pretty lame way to solve this. It seems like eventhough the index function returns an integer, subtracting 1 from it causes the error. Can anyone tell me why I get the error in the first place?
Yuan_Edward
Participant
Posts: 73
Joined: Tue May 10, 2005 6:21 pm
Location: Sydney

Re: Decimal/String manipulation problem

Post by Yuan_Edward »

:oops: No idea
abc123 wrote:TempVal: StripWhiteSpace(Link1.IncomingCol) * 100
Last edited by Yuan_Edward on Wed Jul 18, 2007 5:46 pm, edited 4 times in total.
Edward Yuan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What error is

Code: Select all

Left(TempVal, index(TempVal,'.',1)-1) 
returning? The inital error you posted makes sense, since you might be getting a conversion error on the implicit string-to-number conversion that is occurring when you try to multiply the string by 100.
The derivation copied above will probably generate an error when the 2nd argument is negative (i.e. when you have no "." in your string).
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

The error being returned is:

"Numeric string expected for returned value from function call
'strip_whitespace'. Use default value"
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Check whether using the IsInteger() or StringtoInteger() in your tempval logic resolves this.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Your error is being generated on the maths line, not on the string manupulation one. What is the value of Link1.incomingCol (including spaces) that you are failing on?
Yuan_Edward
Participant
Posts: 73
Joined: Tue May 10, 2005 6:21 pm
Location: Sydney

Re: Decimal/String manipulation problem

Post by Yuan_Edward »

Did you use the same input data for both? I guess there must be non-numeric characters in IncomingCol.

By the way why not use the interal function FLOOR? I guess it does the same thing as your code "Left(TempVal, index(TempVal,'.',1)-1)"??
abc123 wrote:TempVal: StripWhiteSpace(Link1.IncomingCol) * 100

Data type of IncomingCol is char.

If I do:
Left(TempVal, index(TempVal,'.',1)-1)

it gives me the error:

Numeric string expected for returned value from function call 'strip_whitespace'. Use default value.

However, if I do:

Left(Left(TempVal, index(TempVal,'.',1)), Len( Left(TempVal, index(TempVal,'.',1) ))-1)

it works eventhough I think it is a pretty lame way to solve this. It seems like eventhough the index function returns an integer, subtracting 1 from it causes the error. Can anyone tell me why I get the error in the first place?
Edward Yuan
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

Yuan_Edward, I cannot use Floor my integers bigger than Datastage will allow.
Post Reply