TZUpdateSQL statement execution

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
robsonselzelin
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 09.07.2006, 20:56
Contact:

TZUpdateSQL statement execution

Post by robsonselzelin »

Using MySQL database, I've created a table with two fields as primary key, first field INTEGER and second field SMALLINT. On Delphi, using TClientDataSet, when I try to delete a record and after that ApplyUpdates(-1) the record is not deleted.

Using ZSQLMonitor and watching delete statement, I noticed that wasn't the delete statement defined in TZUpdateSQL. Debugging Zeoslib source code, I noticed that Zeos couldn't find the record internaly to delete it, so DataSetProvider have to create a DELETE SQL statement but this statement didn't delete the record in database.

Debugging ZAbstractDataSet.pas unit, when a record is deleted, LocateRecord method is called to find it, then Locate method is called so InternalLocate method is called by Locate method.

InternalLocate call CompareFieldsFromResultSet function to compare the values but when one of those KeyValues is Short (SMALLINT in database), the comparation is:

if CaseInsensitive then
begin
Result := KeyValues.VString =
AnsiUpperCase(ResultSet.GetString(ColumnIndex));
end
else
begin
Result := KeyValues.VString =
ResultSet.GetString(ColumnIndex);
end;

So record is not found by Zeos than DataSetProvider have to generate de DELETE statement, what means that DELETE statement defined by me in TZUpdateSQL is not executed. I switched the SMALLINT field to INT then it works fine but the problem still exists.

I'm using Zeoslib 6.5.1 rev. 79 but it happens with alpha version also.
noelc
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 13.06.2006, 10:54

Post by noelc »

Do you have pfInKey set in the ProviderFlags property for the two primary key fields?
Post Reply