Einzelnen Beitrag anzeigen

Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.475 Beiträge
 
Delphi 12 Athens
 
#13

AW: FireDac den AutoInc value in onBeforePost abfragen. (ist immer -x)

  Alt 2. Sep 2022, 20:36
Der Kernpunkt ist hier UpdateOptions.FetchGeneratorsPoint = gpImmediate . Das sorgt laut Dokumentation dafür, dass die ID schon beim Insert bzw. Append ermittelt wird.
Zitat:
Controls the moment when the next generator value is fetched.

Use FetchGeneratorsPoint to specify the moment when the next generator value is fetched from a database and assigned to an auto-incremental field. The default value is gpDeferred.

The next generator value will be fetched from a generator, specified by the TFDUpdateOptions.GeneratorName/TFDAutoIncField.GeneratorName properties and assigned to the auto-incremental fields, which have pfInUpdate in ProviderFlags.

An auto-incremental field is:

A field of the TFDAutoIncField class.
A field whose name is specified in AutoIncFields.
A field with TField.AutoGenerateValue = arAutoInc.
Generators are supported by InterBase and Firebird. Sequences are supported by Oracle and PostgreSQL DBMSs. For other DBMSs this property has no meaning. The value can be one of the following:

Code:
Mode         Description

gpNone       Do not fetch generator values.
gpImmediate  Fetch values right after starting to append a new record. Normally, this is the value for the TDataSet.Insert or Append methods.
gpDeferred   Fetch values right before posting a new record to a database. Normally, this is the value for the TDataSet.Post or ApplyUpdates methods.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat