Skip to content

EF.DB.FD

FireDac-based database access layer.

TEFDBFDParams class

Utility class used to adapt FireDAC's TFDParams to the standard TParams.

pascal
procedure AssignValuesTo(const ADestination: TFDParams;

Sets the Value property of every parameter in ADestination whose name matches the name of a parameter in the current object to that of the current object's parameter.

TEFDBFDInfo class

Retrieves metadata from a database through FireDAC.

pascal
constructor Create(const AConnection: TFDConnection);

Creates the metadata reader bound to the given FireDAC connection.

pascal
property Connection: TFDConnection read FConnection write FConnection;

The FireDAC connection used to read the database metadata.

pascal
class procedure AddKeyColumnsInPositionOrder(const ADataSet: TDataSet;

Appends to the target lists the column names the open metadata dataset reports, each at the place its COLUMN_POSITION says rather than the place its row happened to arrive in. ADataSet is read from the current record to the end. AReferencedColumnFieldName and ReferencedColumnNames are for a foreign key, which has two lists that come out coupled by position; pass '' and nil for an index. AWhat names the key in the error message.

Public because the two Fetch...Columns methods above are meant to be overridden, and an override needs this to build its lists the same way.

Raises EEFDBError when the positions are not 1..n, each exactly once.

TEFDBFDConnection class

TEFDBConnection implementation over a FireDAC TFDConnection. Applies per-driver connection parameters (MSSQL, FB/IB, Oracle, PostgreSQL, MySQL) and registers a pooled FDManager connection definition so each query can run on its own connection.

pascal
property PoolDefName: string read FPoolDefName;

Name of the FDManager pooled connection definition. CreateDBQuery uses this to acquire a fresh TFDConnection from the pool, so that each query is isolated and nested rules can iterate datasets without the FireDAC MARS-on-shared-connection issue.

pascal
property DriverId: string read GetDriverId;

The FireDAC DriverID for this connection (read from the Connection/DriverID config: e.g. MSSQL, FB, IB, Ora, PG, MySQL).

pascal
procedure AfterConstruction;

Creates the underlying TFDConnection (login prompt disabled) and the connection-string list.

pascal
destructor Destroy;

Frees the underlying TFDConnection and the connection-string list.

pascal
function IsOpen: Boolean;

Returns True if the underlying TFDConnection is connected.

pascal
function ExecuteImmediate(const AStatement: string): Integer;

Executes the statement via TFDConnection.ExecSQL and returns the number of affected rows; wraps errors in EEFDBError.

pascal
procedure InternalStartTransaction;

Starts a transaction on the underlying TFDConnection.

pascal
procedure InternalCommitTransaction;

Commits the current transaction on the underlying TFDConnection.

pascal
procedure InternalRollbackTransaction;

Rolls back the current transaction on the underlying TFDConnection.

pascal
function IsInTransaction: Boolean;

Returns True if the underlying TFDConnection is in a transaction.

pascal
function FetchSequenceGeneratorValue(const ASequenceName: string): Int64;

Sequence generators are not currently supported; always returns 0.

pascal
function GetLastAutoincValue(const ATableName: string = ''): Int64;

Auto-inc value retrieval is not currently supported; always returns 0.

pascal
function CreateDBCommand: TEFDBCommand;

Creates a TEFDBFDCommand linked to this connection.

pascal
function CreateDBQuery: TEFDBQuery;

Creates a query (of GetQueryClass) linked to this connection.

pascal
function GetConnection: TObject;

Returns the underlying FireDAC TFDConnection object.

TEFDBFDCommand class

TEFDBCommand implementation wrapping a FireDAC TFDQuery, used to execute statements that do not return a dataset.

pascal
procedure AfterConstruction;

Creates the internal TFDQuery and parameter list.

pascal
destructor Destroy;

Frees the internal TFDQuery and parameter list.

pascal
function Execute: Integer;

Executes the command and returns the number of affected rows; wraps errors in EEFDBError.

TEFDBFDQuery class

TEFDBQuery implementation wrapping a FireDAC TFDQuery. Outside a transaction it acquires a private pooled TFDConnection so concurrent queries stay isolated; inside a transaction it shares the parent connection.

pascal
procedure AfterConstruction;

Creates the internal TFDQuery and parameter list.

pascal
destructor Destroy;

Frees the internal TFDQuery, the owned connection and the parameter list.

pascal
function Execute: Integer;

Execute and Open are synonims in this class. Execute always returns 0.

pascal
procedure Open;

Opens the underlying TFDQuery, expanding macros and binding parameters; wraps errors in EEFDBError.

pascal
procedure Close;

Closes the underlying TFDQuery.

pascal
function IsOpen: Boolean;

Returns True if the underlying TFDQuery is active.

TEFDBFDConnectionConfig class

FireDAC connection parameters. YAML path: DatabaseRouter/DatabaseName/Connection

TEFDBFDAdapter class

Data access adapter that creates FireDAC-based connections. Registered in the adapter registry under the id 'FD'.

Routines

pascal
function GetUseBooleanFields(ADriverID: string) : boolean;

Returns True if the given FireDAC DriverID binds boolean values as native boolean parameters (True for MSSQL and PG), False when they must be converted to integers (FB, IB, Ora).

Released under Apache License, Version 2.0.