[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sqldb' (#fcl)

# TSQLQuery

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

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

## Declaration

Source position: sqldb.pp line 437

`type TSQLQuery = class(TCustomSQLQuery)`
`public`
`property SchemaType: TSchemaType;` |  | Schema type
`property StatementType: TStatementType;` |  | SQL statement type
`published`
`property MaxIndexesCount;` |  | Maximum allowed number of indexes.
`property FieldDefs;` |  | Definitions of available fields in the underlying database
`property Active;` |  | Is the dataset open or closed.
`property AutoCalcFields;` |  | How often should the value of calculated fields be calculated
`property Filter;` |  | Filter to apply to the data in memory.
`property Filtered;` |  | Is the filter active or not.
`property AfterCancel;` |  | Event triggered after a Cancel operation.
`property AfterClose;` |  | Event triggered after the dataset is closed
`property AfterDelete;` |  | Event triggered after a succesful Delete operation.
`property AfterEdit;` |  | Event triggered after the dataset is put in edit mode.
`property AfterInsert;` |  | Event triggered after the dataset is put in insert mode.
`property AfterOpen;` |  | Event triggered after the dataset is opened.
`property AfterPost;` |  | Event called after changes have been posted to the underlying database
`property AfterScroll;` |  | Event triggered after the cursor has changed position.
`property BeforeCancel;` |  | Event triggered before a Cancel operation.
`property BeforeClose;` |  | Event triggered before the dataset is closed.
`property BeforeDelete;` |  | Event triggered before a Delete operation.
`property BeforeEdit;` |  | Event triggered before the dataset is put in edit mode.
`property BeforeInsert;` |  | Event triggered before the dataset is put in insert mode.
`property BeforeOpen;` |  | Event triggered before the dataset is opened.
`property BeforePost;` |  | Event called before changes are posted to the underlying database
`property BeforeScroll;` |  | Event triggered before the cursor changes position.
`property OnCalcFields;` |  | Event triggered when values for calculated fields must be computed.
`property OnDeleteError;` |  | Event triggered when a delete operation fails.
`property OnEditError;` |  | Event triggered when an edit operation fails.
`property OnFilterRecord;` |  | Event triggered to filter records.
`property OnNewRecord;` |  | Event triggered when a new record is created.
`property OnPostError;` |  | Event triggered when a post operation fails.
`property Database;` |  | The TSQLConnection instance on which to execute SQL Statements
`property Transaction;` |  | Transaction in which to execute SQL statements
`property ReadOnly;`
`property SQL: TStringList;` |  | The SQL statement to execute
`property UpdateSQL: TStringList;` |  | Statement to be used when updating an existing row in the database
`property InsertSQL: TStringList;` |  | Statement to be used when inserting a new row in the database
`property DeleteSQL: TStringList;` |  | Statement to be used when inserting a new row in the database
`property IndexDefs;` |  | List of local index Definitions
`property Params: TParams;` |  | Parameters detected in the SQL statement.
`property ParamCheck: Boolean;` |  | Should the SQL statement be checked for parameters
`property ParseSQL: Boolean;` |  | Should the SQL statement be parsed or not
`property UpdateMode: TUpdateMode;` |  | How to create update SQL statements.
`property UsePrimaryKeyAsKey: Boolean;` |  | Should primary key fields be marked pfInKey
`property DataSource: TDataSource;` |  | Source for parameter values for unbound parameters
`property ServerFilter: string;` |  | Append server-side filter to SQL statement
`property ServerFiltered: Boolean;` |  | Should server-side filter be applied
`property ServerIndexDefs: TServerIndexDefs;` |  | List of indexes on the primary table of the query
`end;`

## Inheritance

`TSQLQuery` |  | Class to handle SQL commands (with or without result set)
`TCustomSQLQuery` |  | Custom Class to handle SQL commands (with or without result set)
`TCustomBufDataset`
?
`TObject`

## 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).

## See also

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

Documentation generated on: Feb 26 2014