problem with procedure TZGenericCachedResolver.PostUpdates

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
User avatar
M56OBER
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 28.10.2005, 12:33
Location: FRANCE

problem with procedure TZGenericCachedResolver.PostUpdates

Post by M56OBER »

Hello !

problem with procedure TZGenericCachedResolver.PostUpdates

When i'm use an edit/post method and on the before post event an other edit/post

Sample

qy.Edit;
qy.FieldbyName('id').asInteger := Getid;
qy.post;

And the GetId method is

function getid:integer;
Var
qy : TZquery;
begin
qy := TZquery.Create(application);
qy.connection := Datamodule1.DATABASE;
qy.sql.text := 'select id from mytable where code="num" ';
qy.Open;
Result := qy.fieldbyName('id').asinteger + 1;
qy.edit
qy.fiedlbyname('id').asInteger := resut;
qy.post;
End;

In the procedure TZGenericCachedResolver.PostUpdates

...
if SQL <> '' then
begin

FillStatement(Statement, SQLParams, OldRowAccessor, NewRowAccessor);
// if Property ValidateUpdateCount isn't set : assume it's true
lValidateUpdateCount := (Sender.GetStatement.GetParameters.IndexOfName('ValidateUpdateCount') = -1)
or StrToBoolEx(Sender.GetStatement.GetParameters.Values['ValidateUpdateCount']); // modif O.B 21/01/2012 }

lUpdateCount := Statement.ExecuteUpdatePrepared;

if (lValidateUpdateCount)
and (lUpdateCount <> 1 ) then
raise EZSQLException.Create(Format(SInvalidUpdateCount, [lUpdateCount])); // modif O.B 21/01/2012}
end;
finally
SQLParams.Free;
end;


IN THAT CASE THE lUpdateCount = 2 do ERROR

Have you a similar problem?
Thank you for help
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

M56OBER,

do you use constraints or indices for your table? On designing the where-clause Zeos asks his MetaData for the best rowi dentifier to have min. one unique-update row. The problem you wrote about seems like the Metadata-informations can't bring up some identifiers and on executing the constructed select-Statement all rows with possible hits (no other fields changed in your example) where changed. On executing internal/prepared statements an Zeos error should be raised if the UpdateCount <>1.

This means there must be two rows in your where table field'ID'.AsInteger = qy.fieldbyName('id').asinteger + 1 ;

Generally its better to use better Unique/PrimaryKey-Constraints, Triggers(FB/IB), stored procedures, Generators or Autoincfields for ID fields..

correct me if i'm wrong...

best regards
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Locked