Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Problem in ppDB.pas with Delphi6.

edited August 2002 in General
In TppCustomDataPipeline.CompareLinkedData, an incompatibility exists for
Delphi6. The same doesn't happen in Delphi5. I discovered the mistake in a
report Master-Detail, where the Master doesn't have any row, but in detail
yes. The operators(less-than, greater-than, less-than-or-equal-to,
greater-than-or-equal-to) with variants(Ex:Null and 1) in Delphi5 returns
false and in Delphi6 it generates exception(EVariantInvalidOpError):

var x, y: Variant;
begin
X := NULL;
y := 1;
If x <> y Then begin
If x > y Then begin / /--Here it is the point
ShowMessage ('Hi!');
end;
end;
end;

the same as it happened in the function(CompareLinkedData) here:

...
if (lDetailFieldValue <> lMasterFieldValue) then
begin
if (lDetailFieldValue > lMasterFieldValue) then
Result := 1
else
Result := -1;

end;
...

to correct that problem I did:

...
if VarIsNull(lDetailFieldValue) then
begin
if (VarIsNull(lMasterFieldValue)) then
Result := 0 {null = null}
else
Result := -1; {null < not(null)}
end

/ /-- Start: Alteration done by me...
else if VarIsNull(lMasterFieldValue) then
begin
Result := 1; {not(null) > null}
end
/ /-- End: Alteration done by me...

else if ((VarType(lMasterFieldValue) = varString) and
(VarType(lDetailFieldValue) = varString)) or
((VarType(lMasterFieldValue) = varOleStr) and
(VarType(lDetailFieldValue) = varOleStr)) then
begin
if lFieldLink.IsCaseSensitive then
begin
if (lFieldLink.CollationType = ctANSI) then
Result := AnsiCompareStr(String(lDetailFieldValue),
String(lMasterFieldValue))
else
Result := CompareStr(String(lDetailFieldValue),
String(lMasterFieldValue));
end
else
begin
if (lFieldLink.CollationType = ctANSI) then
Result := AnsiCompareText(String(lDetailFieldValue),
String(lMasterFieldValue))
else
Result := CompareText(String(lDetailFieldValue),
String(lMasterFieldValue));
end;
end

else
begin

if (lDetailFieldValue <> lMasterFieldValue) then
begin
if (lDetailFieldValue > lMasterFieldValue) then
Result := 1
else
Result := -1;

end;

end;
...

Tato.

Comments

This discussion has been closed.