NOTE: There are many ways this issue can manifest. All the ways clients can encounter it will be listed first, and then the one explanation and solution apply to all those scenarios.
Scenarios
Beginning in Microsoft SQL Server 2016, Microsoft changed the value of the compatibility_level property. These are some of the scenarios that clients could experience which are a result of this change. Additional other issues may occur, and will be added to this document if discovered.
Scenario 1: Issue when client filters on a datetime property
When the client is using the Data Grid Filter/Report definition, Obj-Browse, or a custom SQL command, and is filtering on exposed date/time columns for classes with a BLOB, or classes that have a date/time property as part of the class key, the system may fail to return the correct results.
Example of incorrect results:
The client knows there are 22 records in a table that have a 11/20/yy date. But when they create a report filtering by the pxUpdateDateTime property on the 11/20/yy date, they only receive 10 results.
Details
This situation occurs in an internal class/table (with a BLOB column) which includes one or more exposed datetime properties. The exposed column value is different from the value in the BLOB column, due to increasing precision of the millisecond value and a rounding error.
Embedded (BLOB) value |
Pxupdatedatetime (exposed column) value |
20180713T134733.356 GMT |
2018-07-13 13:47:33.357 |
The reason that fewer results are displayed is because when multiple records have the same timestamp that differs only at the millisecond level, the filter will only display the top-most record.
As the out-of-the-box database tables almost always contain standard system datetime properties, the error could be seen when reporting on any of the Pega database tables.
Scenario 2: Issue when using a datetime property as an internal class key property
A Report Definition or custom SQL may fail to return the correct results when using Obj-Open by class-key property (pzInsKey), including a date/time property, as a filter.
Again, the exposed column’s value is different from the pzInsKey’s precision value.
Pzinskey |
Embedded (BLOB) |
pxCreateDateTime (exposed column) |
Cast_as_datetime2(7) |
RULE-HTML-PARAGRAPH@BASECLASS PYBULKCREATEMESSAGE #20180713T134733.356GMT |
20180713T134733.356 GMT |
2018-07-13 13:47:33.357 |
2018-07-13 13:47:33.3566667 |
Scenario 3: Issue when using a datetime property as an external class key property
An Obj-Browse/Report definition or custom SQL may fail to return the correct results when using Obj-Open by class-key property (pzInsKey), including a date/time property, as a filter.
Obj-Save may fail with a “duplicate key violation” exception.
The Data Type record tab may fail to edit/search/delete the record using the selected value.
TimeCreated |
Cast_as_datetime2(7) |
2023-02-21 11:11:11.357 |
2023-02-21 11:11:11.3566667 |
Failed Filter : SELECT * FROM pega123.pr_Org_Sample_Data_DT1 "PC0" WHERE ( "PC0"."TimeCreated" BETWEEN ? AND ? ) ORDER BY 1 ASC,
2 ASC <2023-02-21 11:11:11.357> <2023-02-21 11:11:12.356>
Scenario 4: Issue when a data type/external class includes a datetime property
An Obj-Browse/Report definition or custom SQL may fail to return the correct results when using a date/time property as a filter.
The Data Type record tab may fail to filter/edit the record using the selected value.
Scenario 5: Issue when a filter uses a function alias of datetime
Any filter using function alias of datetime may return no/incorrect results, including Pega User Defined Functions (UDF).
Scenario 6: Pega UDF is not supported on AWS/MSSQL
Pega UDF is not supported on AWS/MSSQL and Azure/MSSQL 2017+. The client needs to ensure that all the properties for reporting are exposed.
To test whether all properties are exposed, create a Report Definition, and enable an application or ReferencingRuleSet filter. Example:
select pxReferencingRuleSetName, pxReferencingRuleSetVersion, pxReferencingClassName, pxReferencingRuleName, pxWarningName, pxWarningType, pxIsWarningJustified, pyWarningJustifiedMessage from pegarules.pr_index_warnings where pxWarningType = 'Performance' and pxInsIndexedClass = 'Rule-Obj-Report-Definition' and (upper(pxWarningName) like '%OPTIMIZED%' or upper(pxWarningName) like '%EXPOSED%' ) order by pxReferencingRuleSetName
Explanation
Beginning in Microsoft SQL Server 2016, Microsoft changed the value of the compatibility_level property.
|
“Native” or default Compatibility_level value |
MSSQL 2014 |
120 |
MSSQL 2016 |
130 |
MSSQL 2017 |
140 |
MSSQL 2019 |
150 |
The difference in compatibility_level can cause changes with rounding datetime vs. datetime2 values. For details, see: Change in datetime2 implementation in SQL Server 2016
Prior to MSSQL 2016, the compatibility_level value was always 120, which is the value that Pega software expects. The changed values in the later versions of MSSQL can cause a number of issues with Pega software, as described above.
Solution
If the client runs into any of the scenarios below, the short-term solution is to set the compatibility level to what it was for MSSQL 2014, which was 120.
To set compatibility, use these commands:
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL=120
Any of the client DBAs who have “alter” access on the Pega MSSQL 2016, 2017, or 2019 database can run these commands from the SQL Server Management Studio. (No reboot is required.)
For the longer-term solution, Pega is in the process of making changes and testing the setup so our software can accept the higher values - the “native” or “default” value - of the compatibility_level after a database upgrade. This functionality will be available in a future release.