From RAD Studio API Documentation
Jump to: navigation, search


property AutoGenerateValue: TAutoRefreshFlag read FAutoGenerateValue write FAutoGenerateValue default arNone;


__property TAutoRefreshFlag AutoGenerateValue = {read=FAutoGenerateValue, write=FAutoGenerateValue, default=0};


Type Visibility Source Unit Parent
property published
Data.DB TField


Indicates whether the field values can be generated by the server rather than entered by the user.

Use AutoGenerateValue to indicate when field values can be generated by the database. Such fields include autoincrement fields and fields with default values.

Some database drivers can't determine which fields can have values supplied automatically by the server. This can lead to problems when posting edits. For these cases, applications can provide this information by setting the AutoGenerateValue property. Use this property to indicate whether the field is an autoincrement field (arAutoInc), a field with a default value (arDefault), or a field whose value is not automatically generated (arNone).

AutoGenerateValue is not always required. Fields with an AutoGenerateValue property of arNone may still be updated if the driver supplies metadata that indicates it has a default value or an autoincrement value. However, it is good practice to supply this information because not all drivers supply this metadata.

If you do use AutoGenerateValue for any fields that have values generated by the database, you must set AutoGenerateValue to arAutoInc or arDefault on every field whose value is automatically generated by the database. This is because when records are posted, the application immediately executes a query to fetch the automatically-generated values. If you leave an automatically-generated field with AutoGenerateValue set to arNone, this query looks for a record with a blank value on that field, which will fail to locate the correct record.

Warning: AutoGenerateValue can fail in some cases when the automatically-generated field value is on a key field. This is because the query that re-fetches the new field value can't always uniquely locate the record that was just posted.

Note: Trying to change the AutoGenerateValue property when the field's dataset is open generates an exception. Thus, AutoGenerateValue only works with persistent field components, which remain when the dataset is closed.

See Also