Page 1 of 1

TZUpdateSQL statement execution

Posted: 20.07.2006, 13:39
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.

Posted: 21.07.2006, 10:15
by noelc
Do you have pfInKey set in the ProviderFlags property for the two primary key fields?