Sign in Join
FPDoc Onlineexperiment

TCustomSQLQuery.Prepare procedure

Member of TCustomSQLQuerypublicIn unit SQLDB

Prepare a query for execution.

Declaration

pascal
procedure Prepare; virtual

Description

Prepare will prepare the SQL for execution. It will open the database connection if it was not yet open, and will start a transaction if none was started yet. It will then determine the statement type. Finally, it will pass the statement on to the database engine if it supports preparing of queries.

Strictly speaking, it is not necessary to call prepare, the component will prepare the statement whenever it is necessary. If a query will be executed repeatedly, it is good practice to prepare it once before starting to execute it. This will speed up execution, since resources must be allocated only once.

Errors

If the SQL server cannot prepare the statement, an exception will be raised.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.