Last autumn, as I was finishing up my chapters for the 2016
Delphi Developer Days course book, which I wrote with Nick Hodges, Director of
Engineering at Embarcadero Technologies, I received a question about FireDAC
from my German colleague Dr. Holger Flick. He was asking about the relevance of
my ClientDataSet book to some work he was doing with FireDAC. I replied that
the book would help to some extent since so many aspects of Delphi database
development were covered by that book, and that I had used FireDAC and
InterBase for many of that book’s examples.
But his question got me to thinking about the FireDAC
material that I had already written. I had four or five chapters from previous
Delphi Developer Days, I had another three or four articles that I had
published in software-related magazines, and I had several FireDAC
presentations from CodeRage under my belt. I might have half a book there
already. Why not, I thought, my next book will be a
FireDAC book.
I don’t regret that decision at all, though I must say that
even I was surprised at how much work it was to complete this book. This is my
twenty-sixth book (and that’s not counting the eight Delphi Developer Days
books that we’ve published since 2009). I know how much work it takes to write
a book, but this one was different. The amount of research that this book
required was a surprise.
For one thing, I felt that this book should be more than
just a FireDAC book. It should be a book that deserves to be on the shelf of
every Delphi database developer. For the new Delphi database developer who is
unfamiliar with the “Delphi way” of doing things, this book contains
discussions of and demonstrations of the essential techniques that every Delphi
database developer needs to know. This includes concepts like the TDataSet
interface, the current record, and how to read to and write from TFields. (Just a note here, this book assumes you are using Delphi XE6 or later.)
The advanced Delphi database developer, however, is not left
out. These developers may simply want to scan some of the chapters where core
concepts are reviewed, but there are many chapters that delve into some of the
more powerful and exciting features of FireDAC, including virtual field
management, cloned cursors, and cached updates.
So, the short story is that the book was a lot of work, and
in the end, worth the effort.
The book begins with an overview of FireDAC, including its
features and benefits. In chapter 2 you learn the many different ways to
connect to your data, whether you are using one of the mainstream databases and
a FireDAC native driver or are migrating from a legacy file-server database.
Chapter 3 explores how you configure FireDAC to control
nearly every aspect of your data retrieval, in-memory management, and subsequent
database writes. Here you learn about FireDAC dataset property inheritance, and
how to fine tune configurations at the individual component level.
Chapters 4 and 5 demonstrate how you communicate with the
underlying database using dataset components, queries, and stored procedures.
Here I describe the capabilities of these components, as well as some of their
basic configuration, including how to create and use parameterized query and
stored procedure calls. I also cover how to use transactions, as well as how to
monitor the database connections from your running applications.
Chapter 6 introduces the fundamentals of Delphi database
development, introducing concepts like the current record, data-bound
navigation and editing, as well as programmatic navigation and editing. Chapter
7 introduces the creation and use of indexes, while chapters 8 and 9 discuss
searches and filtering, many techniques of which employee indexes.
These four chapters are specifically intended to provide a
core understanding of data-related operations in Delphi. I expect the more
advanced Delphi database developers to quickly scan chapter 6 for anything that
doesn’t look familiar. However, even the advanced developer may glean new and
useful information from a more thorough read of chapters 7 through 9, as
several of the technical reviewers noted (and these guys are definitely
advanced Delphi database developers).
The remaining chapters of this book are dedicated to more
advanced FireDAC technologies that can enable sophisticated solutions in your
database applications. Chapter 10 introduces virtual fields, and shows you how
to use aggregates, Calculated (and InternalCalc) fields, and Lookup fields. It
also examines the FieldsOptions property, a feature introduced in Delphi XE6.
In chapter 11 I cover how to persist your FireDAC datasets
and FDSchemaAdapters to files and streams, as well as how to retrieve that
data. There’s a lot of good stuff in that chapter, including how to control
what data is persisted, and how data being loaded can interact with data that
is already loaded.
In Chapter 12 and 13 I explore the FDMemTable. Here I
discuss the role played by the FDMemTable within the FireDAC landscape, and
then examine many of the techniques that are best suited for FDMemTables.
Topics include the dynamic creation of FDMemTable structure, loading
FDMemTables from other datasets, cloning cursors, and creating nested datasets.
In Chapter 14 I take an in-depth look at the SQL command
preprocessor. Here you learn how to add tremendous flexibility to your SQL
statements, features that permit you to run a common set of SQL statements
across two or more different database servers. The SQL command preprocessor
also gives you unprecedented control over expressions that you add to your SQL,
introducing dozens of FireDAC scalar functions for your use.
Chapter 15 covers Array DML (Data Manipulation Language), a
high-speed mechanism for executing a large number of similar parameterized
queries, for instance, when you are inserting thousands of records into a given
table with an INSERT SQL statement. When you need to update or insert a large
amount of data quickly, this is your tool.
In Chapter 16 I examine a feature that I have been a
champion of for years, cached updates. Here you will learn how to create,
manage, and exploit cached updates to create advanced features for your
applications. I also discuss both the decentralized and centralized models of
cached updates, and provide important guidance for the process of applying
updates and handling potential update failures.
I finish the book with a short chapter on Local SQL,
demonstrating how to configure your FireDAC components to perform SQL queries
on any Delphi dataset or combination of datasets. It’s a powerful technique
that provides for solutions that would previously be difficult or impossible.