Skip to content

TSQLQuery

Class to handle SQL commands (with or without result set).

Declaration

Source position: sqldb.pp line 693

type

  TSQLQuery = class(TCustomSQLQuery)
  public
    property SchemaType;
    property StatementType;
  published
    property MaxIndexesCount;
    property FieldDefs;
    property ObjectView; {d}
    property Active;
    property AutoCalcFields;
    property Filter;
    property Filtered;
    property AfterCancel;
    property AfterClose;
    property AfterDelete;
    property AfterEdit;
    property AfterInsert;
    property AfterOpen;
    property AfterPost;
    property AfterRefresh;
    property AfterScroll;
    property BeforeCancel;
    property BeforeClose;
    property BeforeDelete;
    property BeforeEdit;
    property BeforeInsert;
    property BeforeOpen;
    property BeforePost;
    property BeforeRefresh;
    property BeforeScroll;
    property OnCalcFields;
    property OnDeleteError;
    property OnEditError;
    property OnFilterRecord;
    property OnNewRecord;
    property OnPostError;
    property Database;
    property Transaction;
    property ReadOnly;
    property SQL;
    property InsertSQL;
    property UpdateSQL;
    property DeleteSQL;
    property RefreshSQL;
    property IndexDefs;
    property Options;
    property Params;
    property ParamCheck;
    property Macros;
    property MacroCheck;
    property MacroChar;
    property ParseSQL;
    property UpdateMode;
    property UsePrimaryKeyAsKey;
    property DataSource;
    property Sequence;
    property ServerFilter;
    property ServerFiltered;
    property ServerIndexDefs;
  end;

Description

TSQLQuery exposes the properties and some methods introduced in TCustomSQLQuery. It encapsulates a single SQL statement: it implements all the necessary #fcl.db.TDataset functionality to be able to handle a result set. It can also be used to execute a single SQL statement that does not return data, using the TCustomSQLQuery.ExecSQL method.

Typically, the TSQLQuery.Database property must be set once, the TSQLQuery.Transaction property as well. Then the TSQLQuery.SQL property can be set. Depending on the kind of SQL statement, the Open method can be used to retrieve data, or the ExecSQL method can be used to execute the SQL statement (this can be used for DDL statements, or update statements).

Properties

Member Visibility Description
Active read only published Is the dataset open or closed.
AfterCancel read only published Event triggered after a Cancel operation.
AfterClose read only published Event triggered after the dataset is closed.
AfterDelete read only published Event triggered after a successful Delete operation.
AfterEdit read only published Event triggered after the dataset is put in edit mode.
AfterInsert read only published Event triggered after the dataset is put in insert mode.
AfterOpen read only published Event triggered after the dataset is opened.
AfterPost read only published Event called after changes have been posted to the underlying database.
AfterRefresh read only published Event triggered after the data has been refreshed.
AfterScroll read only published Event triggered after the cursor has changed position.
AutoCalcFields read only published How often should the value of calculated fields be calculated.
BeforeCancel read only published Event triggered before a Cancel operation.
BeforeClose read only published Event triggered before the dataset is closed.
BeforeDelete read only published Event triggered before a Delete operation.
BeforeEdit read only published Event triggered before the dataset is put in edit mode.
BeforeInsert read only published Event triggered before the dataset is put in insert mode.
BeforeOpen read only published Event triggered before the dataset is opened.
BeforePost read only published Event called before changes are posted to the underlying database.
BeforeRefresh read only published Event triggered before the data is refreshed.
BeforeScroll read only published Event triggered before the cursor changes position.
Database read only published The TSQLConnection instance on which to execute SQL Statements.
DataSource read only published Source for parameter values for unbound parameters.
DeleteSQL read only published Statement to be used when deleting a new row in the database.
FieldDefs read only published Definitions of available fields in the underlying database.
Filter read only published Filter to apply to the data in memory.
Filtered read only published Is the filter active or not.
IndexDefs read only published Index definitions for the dataset.
InsertSQL read only published Statement to be used when inserting a new row in the database.
MacroChar read only published Macro delimiter character.
MacroCheck read only published Check for macros in the SQL statement.
Macros read only published Set of macros for this SQL statement.
MaxIndexesCount read only published Maximum allowed number of indexes.
ObjectView read only published
Options read only published Options controlling the behaviour of the dataset.
ParamCheck read only published Should the SQL statement be checked for parameters.
Params read only published Parameters detected in the SQL statement.
ParseSQL read only published Should the SQL statement be parsed or not.
ReadOnly read only published
RefreshSQL read only published Refresh query to re-fetch field values after a DB update.
SchemaType read only public Schema type.
Sequence read only published Sequence to use for auto-generating values using a sequence.
ServerFilter read only published Append server-side filter to SQL statement.
ServerFiltered read only published Should server-side filter be applied.
ServerIndexDefs read only published List of indexes on the primary table of the query.
SQL read only published The SQL statement to execute.
StatementType read only public SQL statement type.
Transaction read only published Transaction in which to execute SQL statements.
UpdateMode read only published How to create update SQL statements.
UpdateSQL read only published Statement to be used when updating an existing row in the database.
UsePrimaryKeyAsKey read only published Should primary key fields be marked pfInKey.
See all Properties

Events

Member Visibility Description
OnCalcFields read only published Event triggered when values for calculated fields must be computed.
OnDeleteError read only published Event triggered when a delete operation fails.
OnEditError read only published Event triggered when an edit operation fails.
OnFilterRecord read only published Event triggered to filter records.
OnNewRecord read only published Event triggered when a new record is created.
OnPostError read only published Event triggered when a post operation fails.
See all Events

See also

Name Description
TSQLTransaction Transaction in which a TSQLQuery is handled.
TSQLConnection An abstract class representing a connection to a SQL Database.
TCustomSQLQuery.ExecSQL Execute a SQL statement that does not return a result set.
TSQLQuery.SQL The SQL statement to execute.