Fórum Query - Qual a finalidade de prepare? #179214

02/09/2003

0

Olá ..

Acabei de ver uma mensagem onde se explica como fazer para verificar se uma query possui algum registro, e olhando suas linhas eu vi o seguinte:

[b:fdc21839f9]qrybaixa.Prepare;
qrybaixa.ExecSQL; [/b:fdc21839f9]

Vc poderia, por favor, me explicar o significado de Prepare e ExecSQL de uma query, pois nunca usei ...

Abraço

Édson Takashi Yano
CMM Systems
Curitiba/PR

[b:fdc21839f9]Título e texto editado pelo Moderador - Leia as regras (AZ) - Mensagem não removida em face de ter sido respondida.[/b:fdc21839f9]


Arc

Arc

Responder

Posts

02/09/2003

Julio2004

procedure Prepare;

Description

Call Prepare to have the 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.

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

Example

if not IBQuery1.Prepared then
begin
IBQuery1.Close;
IBQuery1.Prepare;
IBQuery1.Open
end;

StoredProc1.Params[0].AsString := Edit1.Text;
StoredProc1.Prepare;
StoredProc1.ExecProc;

After,

Executes the SQL statement for the query.

procedure ExecSQL;

Description

Call ExecSQL to execute the SQL statement currently assigned to the SQL property. Use ExecSQL to execute queries that do not return a cursor to data (such as INSERT, UPDATE, DELETE, and CREATE TABLE).

Note:For SELECT statements, call Open instead of ExecSQL.

ExecSQL prepares the statement in SQL property for execution if it has not already been prepared. To speed performance, an application should ordinarily call Prepare before calling ExecSQL for the first time.

Can you understand guy???


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar