Page 1 of 1

:v: Firebird 2.1 , Zeos7dev, ZTable.Post error

Posted: 28.04.2009, 15:29
by SlavoF
Hi,
ZEOSLIB_TESTING_REV617
D2009
Firebird 2.1
ZTable.Edit;
ZTable.FieldByName('x').Value := 1;
ZTable.Post;
ZTable.Edit;
ZTable.FieldByName('x').Value := 2; // if value changed -> OK
ZTable.Post;
ZTable.Edit;
ZTable.FieldByName('x').Value := 2; // if value is same -> error
ZTable.Post;
//---------------
ZTable.Edit;
ZTable.Post; // also error - "-104 Token unknown"

Posted: 28.04.2009, 22:03
by seawolf
Open ZDbcGenericResolver.pas and do this changes

procedure TZGenericCachedResolver.PostUpdates(Sender: IZCachedResultSet;
UpdateType: TZRowUpdateType; OldRowAccessor, NewRowAccessor: TZRowAccessor);
var
Statement : IZPreparedStatement;
SQL : string;
SQLParams : TObjectList;
lUpdateCount : Integer;
lValidateUpdateCount : Boolean;

Temp: TStrings;
begin
if (UpdateType = utDeleted)
and (OldRowAccessor.RowBuffer.UpdateType = utInserted) then
Exit;

SQLParams := TObjectList.Create;
try
case UpdateType of
utInserted:
begin
SQL := FormInsertStatement(SQLParams, NewRowAccessor);
If Assigned(InsertStatement) and (SQL <> InsertStatement.GetSQL) then
InsertStatement := nil;
If (not Assigned(InsertStatement)) and (Trim(SQL) <> '') then
InsertStatement := CreateResolverStatement(SQL);
If Assigned(InsertStatement) then
Statement := InsertStatement;
end;
utDeleted:
begin
SQL := FormDeleteStatement(SQLParams, OldRowAccessor);
If Assigned(DeleteStatement) and (SQL <> DeleteStatement.GetSQL) then
DeleteStatement := nil;
If (not Assigned(DeleteStatement)) and (Trim(SQL) <> '') then
DeleteStatement := CreateResolverStatement(SQL);
If Assigned(DeleteStatement) then
Statement := DeleteStatement;
end;
utModified:
begin
SQL := FormUpdateStatement(SQLParams, OldRowAccessor, NewRowAccessor);
If Assigned(UpdateStatement) and (SQL <> UpdateStatement.GetSQL) then
UpdateStatement := nil;
If (not Assigned(UpdateStatement)) and (Trim(SQL) <> '') then
UpdateStatement := CreateResolverStatement(SQL);
If Assigned(UpdateStatement) then
Statement := UpdateStatement;
end;
else
Exit;
end;

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']);

lUpdateCount := Statement.ExecuteUpdatePrepared;
if (lValidateUpdateCount)
and (lUpdateCount <> 1 ) then
raise EZSQLException.Create(Format(SInvalidUpdateCount, [lUpdateCount]));
end;
finally
SQLParams.Free;
end;
end;

It looks like when you do a
ZTable.Edit;
ZTable.Post;

variable SQL is equal to '' so CreateResolverStatement raise an error
because threre no insert/update/delete to do.

Posted: 29.04.2009, 08:32
by SlavoF
yes,
resolved
:thanks:

Posted: 04.05.2009, 00:21
by mdaems
SVN rev. 631.
(Attention, when marking a thread as [bug_fixed] I usually think nothing should be done anymore)

Mark