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

# TCustomSQLQuery

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

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

## Declaration

Source position: sqldb.pp line 474

`type TCustomSQLQuery = class(TCustomBufDataset)`
`public`
`constructor Create(); override;` |  | Create a new instance of TCustomSQLQuery.
`destructor Destroy; override;` |  | Destroy instance of TCustomSQLQuery
`procedure Prepare; virtual;` |  | Prepare a query for execution.
`procedure UnPrepare; virtual;` |  | Unprepare a prepared query
`procedure ExecSQL; virtual;` |  | Execute a SQL statement that does not return a result set
`procedure SetSchemaInfo(); virtual;` |  | SetSchemaInfo prepares the dataset to retrieve schema info.
`function RowsAffected; virtual;` |  | Return the number of rows (records) affected by the last DML/DDL statement
`function ParamByName();` |  | Return parameter by name
`function MacroByName();` |  | Convenience for Macros.ParamByName
`property Prepared: Boolean; [r]` |  | Is the query prepared ?
`property SQLConnection: TSQLConnection; [rw]` |  | Database as TSQLConnection
`property SQLTransaction: TSQLTransaction; [rw]` |  | Transaction as TSQLTransaction
`procedure ApplyUpdates(); override; overload;` |  | Apply updates and check result
`procedure Post; override;` |  | Post pending changes and optionally apply updates
`procedure Delete; override;` |  | Delete and optionally apply updates
`end;`

## Inheritance

`TCustomSQLQuery` |  | Custom Class to handle SQL commands (with or without result set)
`TCustomBufDataset` |  | Dataset connected to a database.
`TDBDataset` |  | Dataset connected to a database.
`TDataSet` |  | Base class for records-based data-access
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent,IFPObserved`
`TObject`

## Description

TCustomSQLQuery encapsulates a 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 SQL statements that do not return data, using the ExecSQL method.

Do not instantiate a TCustomSQLQuery class directly, instead use the TSQLQuery descendent.

## See also

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

Documentation generated on: May 14 2021