Link to home
Start Free TrialLog in
Avatar of koger
koger

asked on

TQuery.Prepare

What use i prepare. According to the help file, Delphi automatically prepares the query.
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Hi koger,

Delphi Help:

Call Prepare to have the BDE and a remote database server 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.

-----
Igor
Avatar of koger
koger

ASKER

Aha, now I have read it twice
hmm, seems to me (from just reading the help that ITugay so kindly provided) that 'the BDE and a remote database server allocate resources for the query' :)  I guess this is supposed to speed things up.  

I think this is the most unhelpful 'help' I have ever seen in Delphi.. nice.
Avatar of koger

ASKER

hehe :)
Avatar of kretzschmar
? prepare is used to reinitialise any allocated memoryplace on server and clientside, specially if parameters are used, there is a need to reallocate the parameters-buffer on both sides.

usefull for sql-server connections, because some statements are failing the automatism provided by delphi and an explicit prepare call, can resolve some mysterious failures on running this statement.

meikl ;-)
Avatar of koger

ASKER

So normally I would never call prepare ?
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...especcialy if query executed multiply times
------
Igor.