When to call Prepare/Unprepare for stored procedures

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Bourgui
Posts: 4
Joined: Fri 13 Nov 2009 23:01
Location: Ottawa, Canada

When to call Prepare/Unprepare for stored procedures

Post by Bourgui » Wed 03 Feb 2010 21:29

Hi all,

In my application, I have stored procedures (TIBCStoredProc) that are created dynamically when certain forms are created. They are only freed when the form is destroyed.
The stored procedures get call multiple times (hundreds, if not thousands).

My question is, when should I call the prepare/unprepare methods? I can't seem to find clear information on this:
Do I only prepare the SP once at creation, or each time I change the parameter values?

What about UnPrepare?

Thanks!

tsteinmaurer
Posts: 52
Joined: Thu 17 Dec 2009 08:25

Post by tsteinmaurer » Thu 04 Feb 2010 07:03

You need to prepare the stored procedure once and then assign different parameter values before each execution.

As long as it is prepared, Firebird/InterBase holds a compiled version of the stored procedure in its metadata cache. If you don't need the stored procedure anymore, then unprepare it. Unpreparing should automatically happen when the TIBCStoredProc component gets freed e.g. upon freeing the form.

Hope this helps.

Bourgui
Posts: 4
Joined: Fri 13 Nov 2009 23:01
Location: Ottawa, Canada

Post by Bourgui » Thu 04 Feb 2010 13:27

Nice clear explanation, thanks a lot!

Post Reply