Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!

Auto Inc Fields in RAD Server with InterBase

the future of starts demands massive productivity

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 Generators. These provide a unique sequential integer value that can be used to provide a primary key field value. You can create up to 32,767 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.

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

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 SwaggerUI, or the REST Debugger. 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 Auto Inc Fields in RAD Server with InterBase appeared first on Stephen Ball’s Technical Blog.

What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Pre-sales Director at Embarcadero
Related posts

MKS Covid19 App Saving Lives


The RAD Studio I.D.E.


Open Innovation, RAD Server and Enterprise Connectors


Developer Direct – IDE Special – 8th April

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.