View Issue Details

IDProjectCategoryView StatusLast Update
0001647Database Comparer VCLGeneralpublic2020-08-26 12:16
Reportershirokov Assigned Tobarry  
PrioritynormalSeveritycrashReproducibilityalways
Status feedbackResolutionopen 
Summary0001647: TableDataComparer doesn't update records with different keyfield names in master and target
DescriptionThe "field not found" error occurs when trying to compare two tables with different keyfield names.
There are two problems:
1. possible bug in the following code line TTableDataComparer.CompareRecord() function CompareKeyFields()
FldT := fQT.FieldByName(fTableOptionsM.kFlds[i]);
It's obviously, should be fTableOptionsT
2. the TTableDataComparer.RecordUpdate() method generates wrong "where" clause - it uses parameter names from target, but attempts to search fields with such names in master. This causes "field not found" error.
3. datetime files in mssql are transferred incorrectly - milliseconds are omitted, e.g. the '2020-08-25 14:37:24.870' value in master becomes '2020-08-25 14:37:25.000' in target. This causes adding such records in the update script.

See the attached Delphi example.
Steps To Reproducetry to sync two tabels (FB3 and MS-SQL)

Follow the table definition on Firebird3
CREATE TABLE ALARME (
 SPS_NODE SMALLINT NOT NULL,
 TYP SMALLINT NOT NULL,
 ELEMENT SMALLINT NOT NULL,
 JOBID SMALLINT NOT NULL,
 KOMMT TIMESTAMP NOT NULL,
 GEHT TIMESTAMP);
ALTER TABLE ALARME ADD CONSTRAINT PK_ALARME PRIMARY KEY (SPS_NODE,TYP,ELEMENT,JOBID,KOMMT);

Follow the table definition on MS-SQL
CREATE TABLE dbo.Alarme (
 PLC_ID smallint NOT NULL,
 Alarm_no smallint NOT NULL,
 Alarm_On datetime NOT NULL,
 Alarm_Off datetime NOT NULL,
 PRIMARY KEY CLUSTERED (PLC_ID, Alarm_no, Alarm_On)
 WITH (
 PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF,
 ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
ON [PRIMARY]
TagsNo tags attached.

Activities

shirokov

2020-08-25 16:51

administrator  

table-comparer.zip (1,838 bytes)

Issue History

Date Modified Username Field Change
2020-08-25 16:51 shirokov New Issue
2020-08-25 16:51 shirokov Status new => assigned
2020-08-25 16:51 shirokov Assigned To => barry
2020-08-25 16:51 shirokov File Added: table-comparer.zip
2020-08-26 12:16 barry Status assigned => feedback