Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Prepare v Open..
Sun, Jun 9 2019 6:16 PMPermanent Link

Ian Branch

Avatar

Hi Team,
I am reviewing some of the code I did when i was starting out with EDB and came across the folllowing..
{code}
   //
   JobTickets.Prepare;
   JobTickets.Open;
   //
{code}
JobTickets is a TEDBQuery and the record is opened or some editing.
Now, if I read the help on Prepare the Open is redundant.  Yes/No?
Alternatively, again if I read the help on Prepare correctly, the Open will do it anyway.  Yes/No?
Regards,
Ian
Sun, Jun 9 2019 6:17 PMPermanent Link

Ian Branch

Avatar

Hmmm.  Can't edit the above. Frown
If they both effectively achieve the same thing, is there a benefit of one over the other?
Sun, Jun 9 2019 7:48 PMPermanent Link

Raul

Team Elevate Team Elevate

On 6/9/2019 6:17 PM, Ian Branch wrote:
> Hmmm.  Can't edit the above. Frown
> If they both effectively achieve the same thing, is there a benefit of one over the other?

They are not the same thing - Prepare is optional, Open is not (or
ExecSQL in case you're not returning any data).

You have to call Open or ExecSQL.

Prepare is only really useful when you have parameters in your query -
in that case you can prepare once and then execute multiple times which
can be faster than 3 separate prepare/execute steps.

Raul


Sun, Jun 9 2019 7:55 PMPermanent Link

Ian Branch

Avatar

Ahhhh.  Tks Raul.  Much appreciated for the clarification.
In the cases I have I can remove the Prepare.
Ian
Sun, Jun 9 2019 9:49 PMPermanent Link

Raul

Team Elevate Team Elevate

On 6/9/2019 7:55 PM, Ian Branch wrote:
> Ahhhh.  Tks Raul.  Much appreciated for the clarification.
> In the cases I have I can remove the Prepare.

yes - open is enough in your case of no parameters

Raul
Image