Scenario
A Numeric Field Overflow error occurs when the value assigned to an optimized Decimal property does not align with the property's scale or precision. The following error message appears:
ERROR: numeric field overflow Detail: A field with precision 18, scale 9 must round to an absolute value less than 10^9.
Steps to reproduce
- Create a Decimal type property without setting a maximum length or property qualifiers.
- Click Actions > Optimize to report on the property’s ruleform.
- Create a Case type.
- Add the Decimal property as a Field in a step within the Case Type.
- Create a case of the Case Type.
- Assign a value to the Decimal property that exceeds 18 digits or has more than 9 decimal places.
Explanation
This behavior is expected when the Scale and Precision of the Decimal property are not explicitly defined during optimization. By default, optimized Decimal properties create a Database column with a DECIMAL type (or its equivalent, depending on the database vendor), set to a Precision of 18 and a Scale of 9. Values that exceed this default scale or precision trigger a database error when committed.
Workaround
To avoid this error, perform the following actions:
Alter the Database column associated with the optimized property so that the scale and precision accommodate the expected values of the Decimal property.
OR
When creating and/or optimizing new properties, follow these steps to prevent this error from occurring:
- Click the Decimal property and navigate to the Advanced tab.
- Add the pyColumnPrecision and pyColumnScale property qualifiers in the decimal property configuration pane.
- Save your changes.
The pyColumnPrecision and pyColumnScale property qualifiers help scale the precision values of the decimal property. These values are used when the optimization wizard creates a Database column.
Environment
This is an expected behavior observed on all Pega Platform versions.