48a31d6d0a6e90c45bb9d295cd86602a7753fbbc
FAQ/Questions/Changing-Data-Precision.md
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +##Question |
|
| 2 | + |
|
| 3 | +How can I change default data precision setting? |
|
| 4 | + |
|
| 5 | + |
|
| 6 | +##Answer |
|
| 7 | + |
|
| 8 | +When Izenda loads a report that uses a stored procedure, it creates a temporary table to store the values. For string, it creates NVARCHAR(MAX) columns and for numeric fields a DECIMAL(18,6). Therefore, if any field with greater precision such as NUMERIC(22,8) is used, the report then fails with a conversion error as below because it cannot fit the NUMERIC(22,8) value into a DECIMAL(18,6) column. |
|
| 9 | + |
|
| 10 | + |
|
| 11 | +The hard-code default setting, DECIMAL(18,6) can be easily modified by adding below setting code to the Driver (within InitializeReporting() method) . |
|
| 12 | + |
|
| 13 | +### Example) DECIMAL(18,6) (Default) to NUMERIC(22,8) |
|
| 14 | + |
|
| 15 | +```csharp |
|
| 16 | +List<KeyValuePair<string, string>> typeOverrides = AdHocContext.Driver.NativeTypesOverrides; |
|
| 17 | +for (int i = 0; i < typeOverrides.Count; i++) |
|
| 18 | + if (typeOverrides[i].Key == "Decimal") |
|
| 19 | + { |
|
| 20 | + typeOverrides[i] = new KeyValuePair<string, string>(typeOverrides[i].Key, "NUMERIC(22,8)"); |
|
| 21 | + break; |
|
| 22 | + } |
|
| 23 | +AdHocContext.Driver.NativeTypesOverrides = typeOverrides; |
|
| 24 | + |
|
| 25 | +``` |