Code: Select all
procedure TZMySQLCachedResolver.UpdateAutoIncrementFields(
Sender: IZCachedResultSet; UpdateType: TZRowUpdateType; OldRowAccessor,
NewRowAccessor: TZRowAccessor; Resolver: IZCachedResolver);
var
Statement: IZStatement;
ResultSet: IZResultSet;
Plaindriver : IZMysqlPlainDriver;
begin
inherited UpdateAutoIncrementFields(Sender, UpdateType, OldRowAccessor, NewRowAccessor, Resolver);
if not ((FAutoColumnIndex > 0) and
(OldRowAccessor.IsNull(FAutoColumnIndex) or (OldRowAccessor.GetValue(FAutoColumnIndex).VInteger=0))) then
exit;
Plaindriver := (Connection as IZMysqlConnection).GetPlainDriver;
NewRowAccessor.SetLong(FAutoColumnIndex, PlainDriver.GetLastInsertID(FHandle));
{ Statement := Connection.CreateStatement;
ResultSet := Statement.ExecuteQuery('SELECT LAST_INSERT_ID()');
try
if ResultSet.Next then
NewRowAccessor.SetLong(FAutoColumnIndex, ResultSet.GetLong(1));
finally
ResultSet.Close;
Statement.Close;
end;
}
end;
Code: Select all
procedure TZMySQLCachedResolver.UpdateAutoIncrementFields(
Sender: IZCachedResultSet; UpdateType: TZRowUpdateType; OldRowAccessor,
NewRowAccessor: TZRowAccessor; Resolver: IZCachedResolver);
var
//HA 090515 remove unused variables ..
//Statement: IZStatement;
//ResultSet: IZResultSet;
//..
Plaindriver : IZMysqlPlainDriver;
begin
inherited UpdateAutoIncrementFields(Sender, UpdateType, OldRowAccessor, NewRowAccessor, Resolver);
if not ((FAutoColumnIndex > 0) and
(OldRowAccessor.IsNull(FAutoColumnIndex) or (OldRowAccessor.GetValue(FAutoColumnIndex).VInteger=0))) then
exit;
Plaindriver := (Connection as IZMysqlConnection).GetPlainDriver;
NewRowAccessor.SetLong(FAutoColumnIndex, PlainDriver.GetLastInsertID(FHandle));
{ Statement := Connection.CreateStatement;
ResultSet := Statement.ExecuteQuery('SELECT LAST_INSERT_ID()');
try
if ResultSet.Next then
NewRowAccessor.SetLong(FAutoColumnIndex, ResultSet.GetLong(1));
finally
ResultSet.Close;
Statement.Close;
end;
}
end;