EPUB | CHM | PDF

TMySQLDataSet.Methods.Prepare

Top Previous Next

Sends a query for optimization prior to execution.

Syntax:

procedure Prepare;

Description:

Call Prepare to allocate resources for the query and to perform additional optimizations. Calling Prepare before executing a query improves application performance.

Delphi automatically prepares a query if it is executed without first being prepared. After execution, Delphi unprepares the query. When a query will be executed a number of times, an application should always explicitly prepare the query to avoid multiple and unnecessary prepares and unprepares.

Preparing a query consumes some database resources, so it is good practice for an application to unprepare a query once it is done using it. The UnPrepare method unprepares a query.

note When you change the text of a query at runtime, the query is automatically closed and unprepared.

note Note: Prepared statements support is available since MySQL 4.1. If you are using a lower version the Prepare call will be skipped.