Firebird 3.0 Developer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
Firebird 3.0 Developer’s Guide Denis Simonov Version 1.1, 27 June 2020 Preface Author of the written material and creator of the sample project on five development platforms, originally as a series of magazine articles: Denis Simonov Translation of original Russian text to English: Dmitry Borodin (MegaTranslations Ltd) Editor of the translated text: Helen Borrie Copyright © 2017-2020 Firebird Project and all contributing authors, under the Public Documentation License Version 1.0. Please refer to the License Notice in the Appendix This volume consists of chapters that walk through the development of a simple application for several language platforms, notably Delphi, Microsoft Entity Framework and MVC.NET (“Model-View-Controller”) for web applications, PHP and Java with the Spring framework. It is hoped that the work will grow in time, with contributions from authors using other stacks with Firebird. 1 Table of Contents Table of Contents 1. About the Firebird Developer’s Guide: for Firebird 3.0 . 6 1.1. About the Author . 6 1.1.1. Translation… . 6 1.1.2. … and More Translation . 6 1.2. Acknowledgments . 6 2. The examples.fdb Database . 8 2.1. Database Creation Script. 8 2.1.1. Database Aliases . 9 2.2. Creating the Database Objects. 10 2.2.1. Domains . 10 2.2.2. Primary Tables. 11 2.2.3. Secondary Tables . 13 2.2.4. Stored Procedures. 17 2.2.5. Roles and Privileges for Users . 25 2.3. Saving and Running the Script . 26 2.4. Loading Test Data . 27 3. Developing Firebird Applications in Delphi . 28 3.1. Starting a Project . 28 3.2. TFDConnection Component . 28 3.3. Path to the Client Library . 28 3.3.1. Developing for Embedded Applications . 29 3.4. Connection parameters. 29 3.4.1. Connection Parameters in a Configuration File . 31 3.4.2. Connecting to the database. 32 3.5. Working with Transactions . 33 3.5.1. TFDTransaction Component. 33 3.6. Datasets. 37 3.6.1. TFDQuery Component . 38 3.6.2. TFDUpdateSQL component . 42 3.7. TFDCommand component . 45 3.7.1. Types of Command . 45 3.8. Creating the Primary Modules . 46 3.8.1. The Read-only Transaction. 48 3.8.2. The Read/Write Transaction. 49 3.8.3. Configuring the Customer Module for Editing. 49 3.8.4. Implementing the Customer Module . 51 3.8.5. Using a RETURNING Clause to Acquire an Autoinc Value. 54 3.9. Creating a Secondary Module . 55 2 Table of Contents 3.9.1. The Transactions for Invoice Data . 56 3.9.2. A Filter for the Data . 56 3.9.3. Configuring the Module. 56 3.9.4. Doing the Work . 58 3.9.5. The Invoice Details . 63 3.10. The Result. 70 3.11. Conclusion . 70 3.12. Source Code . 71 4. Developing Firebird Applications with Microsoft Entity Framework. 72 4.1. Methods of Interacting with a Database . 72 4.2. Setting Up for Firebird in Visual Studio 2015 . 72 4.2.1. The Installation Process . 73 4.3. Creating a Project . 76 4.3.1. Adding Packages to the Project . 76 4.4. Creating an Entity Data Model (EDM) . 78 4.4.1. The EDM Files . 85 4.5. Creating a User Interface . ..