Page 1 of 1

[ZeosLIB 7 + FB2.1] Error -104 Invalid Token [RESOLVED]

Posted: 29.08.2011, 10:31
by boreas
Hi, I'm sorry for my English is very bad.
While you can easily insert and delete operations to the database I use is easy, when I post after edit "Error Code -104 Invalid Token" error message, and it has been doing for all tables.

Posted: 29.08.2011, 10:41
by boreas
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.

http://zeos.firmos.at/viewtopic.php?t=2 ... alid+token

Posted: 30.08.2011, 20:32
by mdaems
What zeoslib version were you using? Was it a snapshot or the very first alpha of 7.0?
The snapshots should be fixed already.

Mark

Mark