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
problem with procedure TZGenericCachedResolver.PostUpdates
Moderators: gto, EgonHugeist, olehs
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
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
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/
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/