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.
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.
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.
Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.
Start Free Trial
Free Delphi Community Edition
Free C++Builder Community Edition
i don't get it.in Firebird, i just for the RETURNING in the SQL and that's it.that doesn't look so "easily achieved"...what am i missing?