Bde.DBTables.TDatabase.Execute

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Execute(const SQL: string; Params: TParams = nil;  Cache: Boolean = False; Cursor: phDBICur = nil): Integer;

C++

int __fastcall Execute(const System::UnicodeString SQL, Data::Db::TParams* Params = (Data::Db::TParams*)(0x0), bool Cache = false, Bde::phDBICur Cursor = (Bde::phDBICur)(0x0));

Properties

Type Visibility Source Unit Parent
function public
Bde.DBTables.pas
Bde.DBTables.hpp
Bde.DBTables TDatabase

Description

Executes an SQL statement.

Use Execute to execute an SQL statement against the database without the overhead of using a TQuery object. Execute supports Data Definition Language (DDL) SQL statements and those Data Manipulation Language (DDL) SQL statements that do not return result sets. Examples of DDL statements include: CREATE INDEX, ALTER TABLE, and DROP DOMAIN. The DML statements that perform an action on data but do not return a result set are: INSERT, DELETE, and UPDATE.

SQL is a string value containing the statement to be executed.

Params is a value of type TParams and lists any parameters used by the SQL statement. Parameter binding is by index only (not by name). The TParam objects in Params must be in the same order as the the parameters in the SQL statement to which each corresponds. Use the CreateParam method (TParams) to create one TParams object for each parameter in the SQL statement. Use properties and methods of TParam to configure each TParam and to give each a value prior to calling Execute. If the SQL statement does not include any parameters, pass a nil (Delphi) or NULL (C++) value for Params.

Cache specifies whether the prepared SQL statement is cached for reuse within the current transaction. Caching statements can speed their processing if they are used more than once in a transaction.

Cursor allows you to execute a SELECT statement and from it create a Borland Database Engine (BDE) dataset. If SQL is a SELECT statement, Cursor returns the BDE cursor to the result set. Cursor is a pointer to an already existing BDE cursor. There is currently no provision in the VCL to assign the cursor created by this parameter to a dataset component (like TTable). This limits its use to cursors subsequently operated on using BDE API code. The result set returned in Cursor is always read-only. If the SQL statement does not return a result set, pass a nil (Delphi) or NULL (C++) value for Cursor.

Execute returns the number of records affected by executing the SQL statement.

See Also