Page 1 of 1

String to Decimal Issue

Posted: Wed Jul 18, 2018 9:23 pm
by Mohan09
Hi,
The source file which i'm receiving has all fields in char format and target table has decimal field. so have used a transformer to convert StringtoDecimal, while doing so i'm getting an error as "expected precision not found"

Input fieldname (EX_SN_REAL - VARCHAR(30))
Target fieldname (EX_SN_REAL - DECIMAL(30,4))

i'm using the below condition:

Code: Select all

If trimleadingtrailing(nulltoempty(trn.EX_SN_REAL)) = 'N.A.' then SetNull()
 Else if trimleadingtrailing(nulltoempty(trn.EX_SN_REAL)) = '' then SetNull()
 Else if IsValidDecimal('Decimal',StringtoDecimal(trn.EX_SN_REAL)) = 0 then 0
  Else StringtoDecimal(trn.EX_SN_REAL)
Since i'm getting the value 'N.A.' and null, so i'm checking both the cases and set null.

The issue is when i have the value like below
1878989999.1212 - its working fine (length is 15), but if i have the input value more than 15 digits its throwing the error.

if its less than or equal to 15 digits, then string to decimal is adding leading zereos and a space to make it 30 bytes like below
0000000000000001878989999.1212
In case of more than 15 digits, this function is throwing error. Can somebody please help me on this one, Thanks..

Posted: Sat Jul 21, 2018 4:38 am
by ray.wurlod
Welcome aboard.

Please check the syntax of IsValid() versus IsValidDecimal().