RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TQuery.Prepare Method

Sends a query to the Borland Database Engine (BDE) and the server for optimization prior to execution.

Pascal
procedure Prepare;
C++
__fastcall Prepare();

Call Prepare to have the BDE and a remote database server allocate resources for the query and to perform additional optimizations. Preparing a query consumes some database resources, so it is good practice to call UnPrepare once the query is no longer needed. 

If the query will only be executed once, the application does not need to explicitly call Prepare or UnPrepare. Executing an unprepared query generates these calls automatically. However, if the same query is to be executed repeatedly, it is more efficient to prevent these automatic calls by calling Prepare and UnPrepare explicitly.

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

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!