1. Home
  2. /
  3. Docs
  4. /
  5. Articles Report Writer
  6. /
  7. Database Components
  8. /
  9. FD Components
  10. /
  11. FD Table

FD Table

FD Table opens a database table directly without writing any SQL. It returns all rows from the table unless you apply a filter. Use FD Table when you need a simple report against a single table and do not need the flexibility of a SQL query.

If you need to filter rows, join tables, sort results with complex logic, or use parameters and macros, use FD Query instead. FD Table is best suited for straightforward reports where you need all or most of the rows from one table.

FD Table requires an FD Database component to be present in the report.

Adding an FD Table to Your Report

  1. Make sure your report already has an FD Database component configured and connected
  2. Drag an FD Table component onto the designer surface
  3. In the Object Inspector, set the Database property to your FD Database component
  4. Set the TableName property to the name of the table you want to open
  5. Set Active to True to open the table and load the fields

Once Active is True, the fields from the table are available to bind to report bands and objects.

Properties

Database
The FD Database component this table uses to connect. You must set this before the table can open.

TableName
The name of the database table to open. Type the table name exactly as it appears in your database.

Active
Set to True to open the table. Set to False to close it. Articles manages Active automatically when the report runs.

IndexFieldNames
The field name or names to sort the results by. Separate multiple field names with a semicolon. For example CustomerName sorts by customer name, and LastName;FirstName sorts by last name then first name.

IndexName
The name of a database index to use for sorting. Use this as an alternative to IndexFieldNames when you want to use a named index that already exists on the table.

CatalogName
The catalog (database) name. Only needed when connecting to a server that hosts multiple databases and you need to specify which one. Leave blank in most cases.

SchemaName
The schema name. Only needed for databases that use schemas, such as SQL Server. Leave blank in most cases.

Sorting Results

FD Table does not use SQL ORDER BY for sorting. Instead, use the IndexFieldNames property to specify which fields to sort by.

For example, to sort a customer table by name:

  • Set IndexFieldNames to CustomerName

To sort by multiple fields, separate them with a semicolon:

  • Set IndexFieldNames to LastName;FirstName

If you need descending sort order or complex sorting, use FD Query with an ORDER BY clause instead.

Filtering Results

FD Table does not have a WHERE clause. To limit which rows are returned you have two options:

Using a Filter expression
FD Table inherits filter support from the underlying FireDAC dataset. You can set a filter expression in script to limit rows in memory after they are fetched. This is simple but fetches all rows from the database first, which may be slow on large tables.

Using FD Query instead
For large tables or complex filtering, switch to FD Query and write a SQL SELECT with a WHERE clause. This filters at the database level and only returns the rows you need.

Saving Table Data to a File

FD Table can save its current data to a file from PascalScript. Four formats are supported:

SaveAsJSON â€” saves in FireDAC JSON format
SaveAsXML â€” saves in FireDAC XML format
SaveAsBinary â€” saves in FireDAC binary format
SaveAsCSV â€” saves as a comma-separated text file

Example from PascalScript:

FDTable1.SaveAsCSV('C:\Reports\Export\products.csv');

The table must be open (Active = True) before calling any save method. For full details see Saving Data to Files and CSV Import and Export.

When to Use FD Table vs FD Query

Use FD Table when:

  • You need all or most rows from a single table
  • Sorting by a field name is enough
  • You do not need to join other tables
  • You do not need parameters or macros

Use FD Query when:

  • You need to filter rows with a WHERE clause
  • You need to join two or more tables
  • You need to pass runtime values using parameters
  • You need to use macros to change parts of the SQL at runtime
  • You need complex sorting with ORDER BY
  • You are setting up a Master Detail report

Common Problems

The table opens but shows no rows
Check that TableName is set correctly and matches the table name in your database exactly. Some databases are case-sensitive.

The results are not in the order I expect
FD Table does not guarantee any sort order unless you set IndexFieldNames or IndexName. Set IndexFieldNames to the field you want to sort by.

Opening a large table is slow
FD Table fetches all rows from the table. For large tables, switch to FD Query and add a WHERE clause to limit the rows returned.

Related Pages