Page 1 of 1

Decimal/String manipulation problem

Posted: Wed Jul 18, 2007 12:31 am
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?

Re: Decimal/String manipulation problem

Posted: Wed Jul 18, 2007 12:36 am
by Yuan_Edward
:oops: No idea
abc123 wrote:TempVal: StripWhiteSpace(Link1.IncomingCol) * 100

Posted: Wed Jul 18, 2007 12:47 am
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).

Posted: Wed Jul 18, 2007 8:09 am
by abc123
The error being returned is:

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

Posted: Wed Jul 18, 2007 12:56 pm
by us1aslam1us
Check whether using the IsInteger() or StringtoInteger() in your tempval logic resolves this.

Posted: Wed Jul 18, 2007 3:27 pm
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?

Re: Decimal/String manipulation problem

Posted: Wed Jul 18, 2007 5:46 pm
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?

Posted: Thu Jul 19, 2007 10:05 am
by abc123
Yuan_Edward, I cannot use Floor my integers bigger than Datastage will allow.