<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloQuery > TApolloQuery Methods > Prepare |
Declaration
Procedure Prepare;
Description
For use with ExecSQL calls only. Pre-allocates and sets up internal objects to be used to execute the SQL statement. If you do not explicitly call Prepare, the actions it handles will be done automatically each time the SQL expression is evaluated. If the same SQL statement will be used over and over again, it is faster to explicitly call Prepare once before hand. Once the SQL expression will no longer be used, call Unprepare to free all allocated resources associated with this Prepare call.
Prepare is not required for SELECT statements where the SQL expression is activated using the Open method or by setting Active to True.
Delphi Example
In the example ButtonClick event code below, the UPDATE syntax the user enters into the memo window (Memo1) might look something like this:
UPDATE test SET First = "Joe" WHERE (Last = "Smith") and (Age = 35)
// Execute SQL statement (non-SELECT)
procedure TForm1.Button1Click(Sender: TObject);
begin
try
Screen.Cursor := crSQLWait;
ApolloQuery1.SQL.Clear;
ApolloQuery1.SQL.Add( Memo1.Text );
ApolloQuery1.Prepare;
ApolloQuery1.ExecSQL;
finally
Screen.Cursor := crDefault;
ApolloQuery1.UnPrepare; // must call
end;
end;
See Also
ActiveTApolloQuery_Active, ExecSQLExecSQL, UnprepareUnprepare