delphi-firedac
Skill23 starsChanged 8 days agoApache-2.0View on GitHub
Use when writing or fixing plain Delphi code that talks to a database through FireDAC (VCL, FMX, console, service), with no web framework. Covers TFDConnection, connection definitions and pooling, transactions, TFDQuery/TFDCommand/TFDStoredProc, parameters and macros, fetching and RecordCount, array DML, cached updates and ApplyUpdates, EFDDBEngineException, threading, the uses clause per driver, and porting a BDE/ADO/dbExpress app. Triggers on "FireDAC", "TFDConnection", "TFDQuery", "ExecSQL", "ApplyUpdates", "connection pooling", "RecordCount", "array DML", "BDE migration", "Object factory for class".
2 other projects use a version of this.
Adopted by
Most recently taken up by
- adrianosantostreina/delphi-devtheir own version, first seen Nov 1, 2026
- ericwood8/skillstheir own version, first seen Nov 1, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- adrianosantostreina/delphi-dev★ 87same name
- ericwood8/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- delphi-buildSkill
- delphi-code-smellsSkill
- delphi-securitySkill
- delphiSkill
- delphi-testingSkill
- dmvcframework-jsonrpcSkill
- dmvcframework-minimal-apiSkill
- dmvcframework-securitySkill
- dmvcframeworkSkill
- dmvcframework-testingSkill
- dmvcframework-uiSkill
- dmvcframework-webappSkill
- exewatch-delphiSkill
- htmx-skillSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
RecordCountright afterOpenis 50, not the row count: Default RecordCountMode = cmVisible, Mode = fmOnDemand, RowsetSize = 50. - Very specific: line 46
The
OnExecuteErrorevent isprocedure of object: No anonymous method. - Very specific: line 122
Every driver except SQLite (client libraries, native array DML, nested transactions, AutoCommit = False, Kind values other than the five …
- Very specific: line 128
When something here is silent, read the unit under C:\Program Files (x86)\Embarcadero\Studio\<n>.0\source\data\firedac\ (37 = Delphi 13, 23 …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
FireDAC in plain Delphi
For Delphi code that uses FireDAC directly: VCL, FMX, console, service, library. Not for
DelphiMVCFramework TMVCActiveRecord code: that has its own skills, start at dmvcframework.
Language and RTL questions (ownership, try/finally, threads): delphi.
Everything here was run on Delphi 13 (dcc32 37.0) and, unless a line says otherwise, gave the same
result on Delphi 12 (36.0). Every run used the SQLite driver (in-memory or file). Lines marked
"SQLite only" may differ on other servers; "not verified" means exactly that.
Critical rules
- A missing FireDAC unit is a run-time error, not a compile error. The program builds, then the first
OpenraisesObject factory for class {...} is missing ... include unit [FireDAC.X]. The message names the unit. A code-only program needsFireDAC.Stan.Def,FireDAC.Stan.Async,FireDAC.DApt, a driver unit,FireDAC.Comp.Client. Table below, details inreference/uses-and-drivers.md. Close,Freeor a pooledClosewith an open transaction COMMITS.TxOptions.DisconnectActiondefaults toxdCommit;Isolationdefaults toxiUnspecified. An exception does not end the transaction. Usetry ... Commit except Rollback; raise end. For the opposite default setDisconnectAction := xdRollback.- Pooling needs a named connection definition, with
Pooled=Trueinside the definition and nothing else on the component.Params.Pooled := Trueon a private connection raises-507. When the pool is full the nextOpenraises-708at once; it does not wait. Defaults:POOL_MaximumItems=50,POOL_CleanupTimeout=30000,POOL_ExpireTimeout=90000. AddFireDAC.Stan.Pooltouses. RecordCountright afterOpenis 50, not the row count. DefaultRecordCountMode = cmVisible,Mode = fmOnDemand,RowsetSize = 50. Count withselect count(*); never size a loop with it.ApplyUpdatesreturns the number of FAILED rows and does not raise. It is not atomic. With the defaultAutoCommitUpdates = Falsea secondApplyUpdatessends the inserts again (duplicate rows). CallCommitUpdatesafter success.Connection.ApplyUpdates([...])is deprecated.- Array DML is
Q.Execute(ATimes, AOffset).Q.ExecSQL(5, 0)does not compile;Executewith no arguments inserts ONE row and says nothing. - Ownership.
Param.AsStream := ShandsSto the parameter (freeing it yourself is a double free).LoadFromStreamcopies, you free.C.ExecSQL(sql, RS)returns an openTFDQueryyou must free. - Macros eat text.
&and!inside SQL start a macro even in a quoted literal:select 'R&B'returnsR.!nameis pasted raw: injection. Values go in parameters; macros only for identifiers you control. Turn it off withResourceOptions.MacroCreate := False; MacroExpand := Falsebefore assigning the SQL. Openis for SELECT,ExecSQLfor everything else. The wrong one raises (-308/-310), andOpenon an INSERT runs the INSERT first.- NULL needs a type.
ParamByName('x').Clearon a fresh parameter raises-335; setDataTypefirst. - One
TFDConnectionper thread. Share the connection definition (pooled), not the connection object. - The
OnExecuteErrorevent isprocedure of object. No anonymous method. - Non-console, non-VCL programs (services) must call
FDManager.SilentMode := True, or include a wait unit, or the firstOpenfails with theTFDGUIxWaitCursorfactory error.
Skeleton: console program, compiled and run
program FdDemo;
{$APPTYPE CONSOLE}
uses
System.SysUtils, Data.DB,
FireDAC.Stan.Def, FireDAC.Stan.Async, FireDAC.DApt, FireDAC.Phys.SQLite,
FireDAC.Comp.Client;
var
C: TFDConnection;
Q: TFDQuery;
begin
C := TFDConnection.Create(nil);
try
C.DriverName := 'SQLite';
C.Params.Database := ':memory:';
C.Open;
C.ExecSQL('create table t(id integer primary key, n text)');
C.ExecSQL('insert into t(n) values(:n)', ['alpha']); // array of Variant
Q := TFDQuery.Create(nil);
try
Q.Connection := C;
Q.SQL.Text := 'select * from t where n = :n';
Q.ParamByName('n').AsString := 'alpha';
Q.Open;
while not Q.Eof do
begin
Writeln(Q.FieldByName('id').AsInteger, ' ', Q.FieldByName('n').AsString);
Q.Next;
end;
finally
Q.Free;
end;
finally
C.Free;
end;
end.For a VCL form add FireDAC.VCLUI.Wait (FMX: FireDAC.FMXUI.Wait, compiled only). In the IDE, dropping the
components adds the units for you; that is why the same code "works on the form" and fails in a console.
Which unit declares what
| Identifier | Unit |
TFDConnection, TFDQuery, TFDCommand, TFDStoredProc, TFDTransaction, TFDMemTable, TFDTable, TFDUpdateSQL, FDManager | FireDAC.Comp.Client |
TFDDataSet, rtInserted / rtModified / rtDeleted / rtUnmodified | FireDAC.Comp.DataSet |
TFDParam, TFDParams, TFDMacro, mdRaw, mdIdentifier | FireDAC.Stan.Param |
fmAll, cmTotal, xdCommit, xdRollback, xiReadCommitted | FireDAC.Stan.Option |
TFDErrorAction, eaSkip, eaFail | FireDAC.Stan.Intf |
EFDException, EFDDBEngineException, ekUKViolated | FireDAC.Stan.Error |
TFDGUIxWaitCursor (component only) | FireDAC.Comp.UI |
driver: SQLite, MySQL, PG, MSSQL, Ora, FB, IB, MSAcc, ODBC | FireDAC.Phys.<Name> (Ora is FireDAC.Phys.Oracle) |
Reference index
| Open this | When |
reference/uses-and-drivers.md | Object factory ... is missing; uses for a driver, console, service, VCL, FMX; wait cursor; storage units |
reference/connections-and-threads.md | connection definitions, pooling parameters and exhaustion, threads |
reference/transactions.md | StartTransaction/Commit/Rollback, defaults, nested, AutoCommit |
reference/commands-params-macros.md | Open vs ExecSQL, parameter types and NULL, streams, macros and the &/! rules |
reference/fetching-and-bulk.md | RecordCount, FetchOptions, array DML, Connection.ExecSQL with a result set |
reference/cached-updates.md | CachedUpdates, ApplyUpdates, CommitUpdates, duplicates after a second apply |
reference/errors.md | EFDDBEngineException, Kind, decoding -NNN messages |
reference/migration.md | porting BDE / ADO / dbExpress code: what compiles, what changes silently, migrate units |
Not verified
- Every driver except SQLite (client libraries, native array DML, nested transactions,
AutoCommit = False,Kindvalues other than the five tested, stored procedures,LoginPrompt). FireDAC.FMXUI.Waitin a real FMX application;TFDSchemaAdapter;TFDScript; async execution modes.- Several independent transactions on one connection (
TFDTransaction). - Sharing one connection across threads: treated as unsupported on source evidence only.
When something here is silent, read the unit under C:\Program Files (x86)\Embarcadero\Studio\<n>.0\source\data\firedac\
(37 = Delphi 13, 23 = Delphi 12) and write a 20-line console program on SQLite before answering.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

