FireDAC.Comp.Client.TFDCustomConnection.ExecSQL

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

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++

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

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
function public
FireDAC.Comp.Client.pas
FireDAC.Comp.Client.hpp
FireDAC.Comp.Client TFDCustomConnection


Beschreibung

Führt eine SQL-Anweisung aus und gibt die Anzahl der betroffenen Zeilen zurück.

ExecSQL akzeptiert bestimmte Kombinationen der folgenden Parameter:

  • ASQL ist ein String, der die auszuführende SQL-Anweisung enthält.
  • AResultSet ist eine Instanz von TDataSet, die ExecSQL mit den Daten füllt, die das Datenbankmanagementsystem als Antwort auf Ihre SQL-Anweisung zurückgibt.
  • AParams ist entweder ein Varianten-Array oder eine Instanz von TFDParams, die einen oder mehrere Parameter zum Füllen der SQL-Anweisung angibt.
  • ATypes ist ein Feldtypen-Array, das die Typen der angegebenen Parameter festlegt. Verwenden Sie ftUnknown, wenn Sie den Typ eines bestimmten Parameters nicht angeben möchten.
  • AIgnoreObjNotExists legt fest, ob ExecSQL Exceptions der Art "Objekt ist nicht vorhanden" ignorieren (verbergen) muss (True) oder nicht (False). Diese Methode ist beispielsweise dann hilfreich, wenn Sie DROP-Anweisungen für Datenbankmanagementsysteme ausführen, die die Syntax DROP IF EXISTS nicht unterstützen. Signaturen, für die Sie keinen Wert für AIgnoreObjNotExists angeben können, geben alle Exceptions weiter.

Beispiel

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]);

Siehe auch