StringToDecimal

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
Madhusv
Participant
Posts: 35
Joined: Sat May 07, 2005 1:38 am
Contact:

StringToDecimal

Post 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
Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Convert function in transformer

Post 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
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
Madhusv
Participant
Posts: 35
Joined: Sat May 07, 2005 1:38 am
Contact:

Post 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
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post 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
Post Reply