Page 1 of 1

StringToDecimal

Posted: Tue Sep 27, 2005 8:07 am
by Madhusv
Hi All,

I am getting the below error while converting from string to decimal.

Case 1:
APT_CombinedOperatorController,1: A numeric string was expected, got " "; using Decimal, the default value.


String Data Type: Char[6]
Decimal Data Type: Decimal[11,2]

I am getting this warning only when there is blank in the Data, Also i am using setnull() if value is blank using below expr.

If (Len(Trim(Field_Name))=0) Then SetNull()
Else
StringToDecimal(Trim(Field_Name));

Also in another case i am using the same function there i am getting diffrent problem.

Case 2:

Source Data Type: Char[9] data looks like this +999.9999
Target data Type : Decimal[7,4]

Here also i am using same logic to set the blank values to null, But if blank is there i am getting it has 0 in the target.

Please do the needful.

Regards,
Madhu



Regards,
Madhu

Convert function in transformer

Posted: Wed Sep 28, 2005 4:35 am
by Nageshsunkoji
Hi,
In case 1 : If u r input column field_name=blank means it contains null.So,u want to handle nulls By using If isnull(field_name) then 0.0 else Stringtodecimal(field_name)
In case 2 : If u r string contains +999.999,then first u want to remove + from string by using function convert("+",' ',field_name).Put this value in a stage variable FieldSVar.Then use function stringtodecimal(trim(FieldSVar)).

As per my knowldge it will solve u r problem.

Thanks&Regards
Nagesh

Posted: Wed Sep 28, 2005 8:40 am
by Madhusv
Hi Nagesh,

Thanks for the Reply,

Case 1:The Problem is If data is blank means data is having spaces,beacuse the record is of fixed width, Also if blank/space is there iw ant to set that to NULL(Not to 0.0).

Case 2: Here from source i am splitting this field(9) into two fileds one is of 1 and another of 8, In the first field i am taking out the + sign, and in the next field data.
Here also i want to set if the value is blank to NULL.


Regards,
Madhu

Posted: Wed Sep 28, 2005 9:31 am
by kumar_s
Hi,
Try using modify stage
StringCol:string[7] = string_from_decimal[fix_zero,suppress_zero](Decimalcol)
fix_zero might serve your purpose.

regards
kumar