Solved

TQuery.Prepare

Posted on 2001-07-08
9
597 Views
Last Modified: 2008-03-10
What use i prepare. According to the help file, Delphi automatically prepares the query.
0
Comment
Question by:koger
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 6262356
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
0
 

Author Comment

by:koger
ID: 6262522
Aha, now I have read it twice
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6262537
:-)
0
 

Expert Comment

by:felonious
ID: 6263552
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:koger
ID: 6264258
hehe :)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6264363
? 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 ;-)
0
 

Author Comment

by:koger
ID: 6274906
So normally I would never call prepare ?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 6275865
>So normally I would never call prepare ?
i need it not often to call prepare
(atleast i needed it only one time to do it
for a complex query with alots parameters)
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6276095
...especcialy if query executed multiply times
------
Igor.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
select query - oracle 16 94
Convert a string into a TDateTime 5 50
creating threads in delphi 1 82
Convert MS Word document to a PDF file 9 63
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now