FireDAC.Comp.Client.TFDCustomConnection.ExecSQL

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function ExecSQL(const ASQL: String; AIgnoreObjNotExists: Boolean = False): LongInt; overload;
function ExecSQL(const ASQL: String; const AParams: array of Variant): LongInt; overload;
function ExecSQL(const ASQL: String; const AParams: array of Variant;  const ATypes: array of TFieldType): LongInt; overload;
function ExecSQL(const ASQL: String; AParams: TFDParams): LongInt; overload;
function ExecSQL(const ASQL: String; AParams: TFDParams; var AResultSet: TDataSet): LongInt; overload;
function ExecSQL(const ASQL: String; var AResultSet: TDataSet): LongInt; overload;

C++

int __fastcall ExecSQL(const System::UnicodeString ASQL, bool AIgnoreObjNotExists = false)/* overload */;
int __fastcall ExecSQL(const System::UnicodeString ASQL, System::Variant const *AParams, const int AParams_High)/* overload */;
int __fastcall ExecSQL(const System::UnicodeString ASQL, System::Variant const *AParams, const int AParams_High, Data::Db::TFieldType const *ATypes, const int ATypes_High)/* overload */;
int __fastcall ExecSQL(const System::UnicodeString ASQL, Firedac::Stan::Param::TFDParams* AParams)/* overload */;
int __fastcall ExecSQL(const System::UnicodeString ASQL, Firedac::Stan::Param::TFDParams* AParams, Data::Db::TDataSet* &AResultSet)/* overload */;
int __fastcall ExecSQL(const System::UnicodeString ASQL, Data::Db::TDataSet* &AResultSet)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomConnection

Description

Executes a SQL command and returns the number of affected rows.

ExecSQL accepts certain combinations of the following parameters:

  • <ASQL> is a string containing the SQL statement that you want to execute.
  • <AResultSet> is an instance of TDataSet that ExecSQL fills with the data that the database management system returns as a response to your SQL statement.
  • <AParams> is either an array of variants or an instance of TFDParams that specified one or more parameters to fill the specified SQL statement.
  • <ATypes> is an array of field types that indicates the types of the specified parameters. Use ftUnknown if you do not want to specify the type of a certain parameter.
  • <AIgnoreObjNotExists> determines if ExecSQL must ignore (hide) "object does not exist" exceptions (True) or not (False). This method is useful, for example, when you execute DROP statements on database management systems that do not support the DROP IF EXISTS syntax. Signatures where you cannot specify a value for <AIgnoreObjNotExists> propagate all exceptions.

Example

FDConnection1.ExecSQL('truncate table tab1');
FDConnection1.ExecSQL('drop table tab2', True);
FDConnection1.ExecSQL('delete from mytab where id > :p1', [1000]);
FDConnection1.ExecSQL('update mytab where id = :p1 set blobfld = :blb',
  [1000, StringOfChar('x', 100000)], [ftInteger, ftBLOB]);

See Also