Articles Auto Inc Fields in RAD Server with InterBase by Stephen Ball

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,439
Credits
574
Auto Inc Fields in RAD Server with InterBase
[SHOWTOGROUPS=4,20]
Stephen Ball
9/4/2020

How to create Auto Incremental Fields in RAD Server with InterBase, FireDAC and TEMSDataSetResource
One key feature when asking a remote server to add a record is to get the new record ID value returned. Thankfully this is easily achieved with InterBase and FireDAC via RAD Server with TEMSDataSetResource
InterBase has a concept of Для просмотра ссылки Войди или Зарегистрируйся. These provide a unique sequential integer value that can be used to provide a primary key field value. You can create Для просмотра ссылки Войди или Зарегистрируйся Generators in an InterBase database, but typically you would create one for the database or create and name one for use per table.
FireDAC Query UpdateOptions AutoInc
Part of the FireDAC framework is the ability to treat database fields as Auto-Incremental Fields. For Databases that do not have an AutoIncremental field data type, you can set the UpdateOptions properties to define the Generator and key fields.

The video uses a simple example with a Generator called G_STUDENT (named as it provides the ID to be used for the STUDENT table in the sample database.
With the query selected at design time, select the UpdateOptions property in the Object inspector. There are two properties to set.
  • AutoIncFields – Which you need to set to the field to be incremented.
  • GeneratorName – Which provides a drop down to the database generators for you to select from.
FireDAC_UpdateOptions_AutoInc.png


The other option to set is on the TEMSDataSetResource. Here, set the KeyFields to the Primary Key Field (ie for the example, STUDENT_ID)
TEMSDataSetResource_KeyFields.png


While you don’t need to add the fields to the query using the FieldEditor (Right-click on the Query and select Fields Editor…), if you do, you will see the field is now set as an TFDAutoIncField, rather than a normal integer field.
To test the setup, you can either use Для просмотра ссылки Войди или Зарегистрируйся, or the Для просмотра ссылки Войди или Зарегистрируйся. As this has been covered before in other posts, I will not repeat it here, but for quick reference, the video below starts at the point where testing of the end point happens using the REST Debugger.

The post Для просмотра ссылки Войди или Зарегистрируйся appeared first on Для просмотра ссылки Войди или Зарегистрируйся.

[/SHOWTOGROUPS]
 
Последнее редактирование: