Declaration¶
Source position: sqldb.pp line 370
type
TCustomSQLStatement = class(TComponent)
public
constructor Create;
destructor Destroy;
procedure Prepare;
procedure Execute;
procedure Unprepare;
function ParamByName : TParam;
function RowsAffected : TRowsCount;
property Prepared: Boolean; {r}
end;
Inheritance¶
Description¶
TCustomSQLStatement is a light-weight object that can be used to execute SQL statements on a database. It does not support result sets, and has none of the methods that a TDataset component has. It can be used to execute SQL statements on a database that update data, execute stored procedures and DDL statements etc.
The TCustomSQLStatement is equivalent to TSQLQuery in that it supports transactions (in the Transaction property) and parameters (in the Params property) and as such is a more versatile tool than executing queries using TSQLConnection.ExecuteDirect.
To use a TCustomSQLStatement is simple and similar to the use of TSQLQuery: set the Database property to an existing connection component, and set the Transaction property. After setting the SQL property and filling Params, the SQL statement can be executed with the Execute method.
TCustomSQLStatement is a parent class. Many of the properties are only made public (or published) in the TSQLStatement class, which should be instantiated instead of the TCustomSQLStatement class.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| Prepared read only | public | Is the statement prepared or not. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| Create | public | Create a new instance of TCustomSQLStatement. |
| Destroy | public | Destroy a TCustomSQLStatement instance. |
| Execute | public | Execute the SQL statement. |
| ParamByName | public | Find a parameter by name. |
| Prepare | public | Prepare the statement for execution. |
| RowsAffected | public | Number of rows affected by the SQL statement. |
| Unprepare | public | Unprepare a previously prepared statement. |
See also¶
| Name | Description |
|---|---|
| TSQLStatement | Class to execute non-select SQL statements. |
| TDataset | |
| TSQLQuery | Class to handle SQL commands (with or without result set). |
| TSQLStatement.Transaction | The transaction in which the SQL statement should be executed. |
| TSQLStatement.Params | List of parameters. |
| TCustomSQLStatement.Execute | Execute the SQL statement. |
| TSQLStatement.Database | Database instance to execute statement on. |
| TSQLConnection.ExecuteDirect | Execute a piece of SQL code directly, using a Transaction if specified. |