From RAD Studio API Documentation
Jump to: navigation, search


function ExecSQL(ExecDirect: Boolean = False): Integer; override;


virtual int __fastcall ExecSQL(bool ExecDirect = false);


Type Visibility Source Unit Parent
function public
Data.SqlExpr TSQLDataSet


Executes a query or stored procedure that does not return a set of records.

Call ExecSQL to execute an SQL command that does not return a set of records. This command is a query other than a SELECT query, such as an INSERT, UPDATE, DELETE, or CREATE TABLE query.

ExecDirect indicates that the query does not need to be prepared before it is executed. This parameter can be set to true if the query does not include any parameters. When ExecDirect is false, the query will be prepared before it is executed. Even when ExecDirect is false, you can avoid preparing the query every time ExecSQL is called by setting the Prepared property to true before calling ExecSQL the first time.

ExecSQL returns the number of rows affected by the executed command. This becomes the value of the RowsAffected property.

Note: Do not use ExecSQL for commands that return data. These include any use of the ctTable command type, SELECT queries, and stored procedures that return a cursor. When the command returns data, use the Open method or set the Active property to true.

See Also