Data.SqlExpr.TSQLConnection.Execute

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Execute(const SQL: string; Params: TParams): Integer; overload;
function Execute(const SQL: string; Params: TParams;  var ResultSet: TDataSet): Integer; overload;
function Execute(const SQL: string; Params: TParams;  ResultSet: Pointer): Integer; overload; deprecated 'Use overloaded method instead';

C++

int __fastcall Execute(const System::UnicodeString SQL, Data::Db::TParams* Params)/* overload */;
int __fastcall Execute(const System::UnicodeString SQL, Data::Db::TParams* Params, Data::Db::TDataSet* &ResultSet)/* overload */;
int __fastcall Execute _DEPRECATED_ATTRIBUTE1("Use overloaded method instead") (const System::UnicodeString SQL, Data::Db::TParams* Params, void * ResultSet)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
Data.SqlExpr.pas
Data.SqlExpr.hpp
Data.SqlExpr TSQLConnection

Description

Executes an SQL command on the server.

Call Execute to execute a single command on the server without the overhead of using an SQL dataset. Execute is especially useful for statements that do not return a result set such as data definition language (DDL) statements.

SQL is the command to execute.

Params is a TParams object that contains any parameters used by the SQL statement. Parameter binding is by index only (not by name), so the order of parameters is important and the order of the TParam objects in Params corresponds to the order of the parameters in the SQL statement. Use properties and methods of TParams to create a TParams object, add TParam objects for each parameter, and assign parameter properties such as datatype and value. If the SQL statement does not include any parameters, pass a nil (Delphi) or NULL (C++) value for Params.

ResultSet is a pointer to a variable of type TCustomSQLDataSet*. If the SQL statement returns a cursor, Execute creates a new TCustomSQLDataSet instance and populates it with the result set. The new TCustomSQLDataSet reference is returned as the value to which ResultSet points. If the SQL statement does not return a result set, pass a nil (Delphi) or NULL (C++) value for ResultSet. TPSResult is is set to Pointer for native code and TObject for managed code.

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

Tip: If the SQL statement does not include any parameters, you can use the ExecuteDirect method instead.

See Also